Skip to main content

sci-dl: help you download SciHub PDF programmatically

Project description

sci-dl: help you download SciHub PDF faster

Features

  1. configuration file support.
  2. search by Google Scholar(coming soon).
  3. download using DOI.
  4. custom SciHub mirror url.
  5. proxy support.
  6. failure retry.
  7. captacha support(coming soon).
  8. a Python library that can be embedded in your program.

Installation

use as command line software

pip install 'sci-dl[cmd]'

use as Python library

pip install sci-dl

Usage

use as command line software

  1. initialization configuration file
sci-dl init-config

follow the prompt to create the configuration file.

  1. download using DOI
sci-dl dl -d '10.1016/j.neuron.2012.02.004'
# 10.1016/j.neuron.2012.02.004 is the article DOI you want to download

use as Python library

sci_dl.SciDlError raises when exception happens.

if you don't have a proxy

from sci_dl import dl_by_doi


config = {
    'base_url': 'https://sci-hub.se',  # sci-hub URL
    'retries': 5,  # number of failure retries
    'use_proxy': False  # means you don't want to use a proxy
}

response = dl_by_doi('10.1016/j.neuron.2012.02.004', config)

if you use a proxy

from sci_dl import dl_by_doi


config = {
    'base_url': 'https://sci-hub.se',  # sci-hub URL
    'retries': 5,  # number of failure retries
    'use_proxy': True,  # means you don't want to use a proxy
    'proxy_protocol': 'socks5',  # available protocols: http https socks5
    'proxy_user': None,  # proxy user, if your proxy don't need one, you can pass None
    'proxy_password': None,  # proxy password, if your proxy don't need one, you can pass None
    'proxy_host': '127.0.0.1',  # proxy host
    'proxy_port': 1080  # proxy port
}

response = dl_by_doi('10.1016/j.neuron.2012.02.004', config)

how to save response?

get all content one time

with open('xxx.pdf', 'wb') as fp:
    fp.write(response.content)

chunk by chunk

with open('xxx.pdf', 'wb') as fp:
    for chunk in response.iter_content(1024):  # 1024 is the chunk size
        fp.write(chunk)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sci-dl-0.1.2.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

sci_dl-0.1.2-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page