Package: scidownl
SciDownlAn unofficial api for downloading papers from SciHub.Support downloading with DOI, PMID or TITLE.Easy to update newest SciHub domains.Ready for changes: Encapsulate possible future changes of SciHub as configurations.Support proxies.Quick Usage# Download with a DOI and filenmae is the paper's title.$scidownldownload--doihttps://doi.org/10.1145/3375633# Download with a PMID and a user-defined filepath$scidownldownload--pmid31395057--out./paper/paper-1.pdf# Download with a title$scidownldownload--title"ImageNet Classification with Deep Convolutional Neural Networks"--out./paper/paper-1.pdf# Download with a proxy: SCHEME=PROXY_ADDRESS$scidownldownload--pmid31395057--out./paper/paper-1.pdf--proxyhttp=socks5://127.0.0.1:7890InstallationInstall with pipScidownl could be easily install with pip.$pip3install-UscidownlInstall from source code$gitclonehttps://github.com/Tishacy/SciDownl.git
$cdScidownl&&python3setup.pyinstallUsageCommand line tool$scidownl-h
Usage:scidownl[OPTIONS]COMMAND[ARGS]...CommandlinetooltodownloadpdfsfromScihub.

Options:-h,--helpShowthismessageandexit.

Commands:configGetglobalconfigs.domain.listListavailableSciHubdomainsinlocaldb.domain.updateUpdateavailableSciHubdomainsandsavethemtolocaldb.downloadDownloadpaper(s)byDOIorPMID.1. Update available SciHub domains$scidownldomain.update--help
Usage:scidownldomain.update[OPTIONS]UpdateavailableSciHubdomainsandsavethemtolocaldb.

Options:-m,--modeTEXTupdatemode,couldbe'crawl'or'search',defaultmodeis'crawl'.-h,--helpShowthismessageandexit.There are 2 update modes that you could specify with an option:-mor--modecrawl: [Default] Crawling the real-time updated SciHub domains website (aka, SciHub domain source) to get available SciHub domains. The SciHub domain source website url is configured in the global config file in the section[scihub.domain.updater.crawl]with the key ofscihub_domain_source. You could usescidownl config --locationto show the location of the global config file and edit it.; Global config file: global.ini; ...[scihub.domain.updater.crawl]scihub_domain_source=http://tool.yovisun.com/scihub; ...An example of usingcrawlmode:$scidownldomain.update--modecrawl[INFO]|2022/03/0721:07:50|Found6validSciHubdomainsintotal:['http://sci-hub.ru','http://sci-hub.se','https://sci-hub.ru','https://sci-hub.st','http://sci-hub.st','https://sci-hub.se'][INFO]|2022/03/0721:07:50|Saved6SciHubdomainstolocaldb.search：Generate combinations according to the rules of SciHub domains and search for available SciHub domains. This will take longer thancrawlmode.An example of usingsearchmode:$scidownldomain.update--modesearch[INFO]|2022/03/0721:08:44|# Search valid SciHub domains from 1352 urls[INFO]|2022/03/0721:08:48|# Found a SciHub domain url: https://sci-hub.ru[INFO]|2022/03/0721:08:48|# Found a SciHub domain url: https://sci-hub.st...[INFO]|2022/03/0721:09:04|Found6validSciHubdomainsintotal:['https://sci-hub.ru','https://sci-hub.st',...][INFO]|2022/03/0721:09:04|Saved6SciHubdomainstolocaldb.2. List all saved SciHub domainsSciDownl useSQLiteas the local database to store all updated SciHub domains locally. You can list all saved SciHub domains with the commanddomain.list.$scidownldomain.list
+--------------------+----------------+---------------+|Url|SuccessTimes|FailedTimes||--------------------+----------------+---------------||http://sci-hub.ru|0|0||https://sci-hub.ru|0|0||https://sci-hub.st|0|0||http://sci-hub.st|0|0||https://sci-hub.se|0|0||http://sci-hub.se|0|0|+--------------------+----------------+---------------+In addition to the easy-to-understand Url column, theSuccessTimescolumn is used to record the number of successful paper downloads using this Url, and theFailedTimescolumn is used to record the number of failed paper downloads using this Url. These two columns are used to calculate the priority of choosing a SciHub domain when downloading papers.3. Download papers$ scidownl download --help
Usage: scidownl download [OPTIONS]

  Download paper(s) by DOI or PMID.

Options:
  -d, --doi TEXT         DOI string. Specifying multiple DOIs is supported,
                         e.g., --doi FIRST_DOI --doi SECOND_DOI ...
  -p, --pmid INTEGER     PMID numbers. Specifying multiple PMIDs is supported,
                         e.g., --pmid FIRST_PMID --pmid SECOND_PMID ...
  -t, --title TEXT       Title string. Specifying multiple titles is
                         supported, e.g., --title FIRST_TITLE --title
                         SECOND_TITLE ...
  -o, --out TEXT         Output directory or file path, which could be an
                         absolute path or a relative path. Output directory
                         examples: /absolute/path/to/download/,
                         ./relative/path/to/download/, Output file examples:
                         /absolute/dir/paper.pdf, ../relative/dir/paper.pdf.
                         If --out is not specified, paper will be downloaded
                         to the current directory with the file name of the
                         paper's title. If multiple DOIs or multiple PMIDs are
                         provided, the --out option is always considered as
                         the output directory, rather than the output file
                         path.
  -u, --scihub-url TEXT  Scihub domain url. If not specified, automatically
                         choose one from local saved domains. It's recommended
                         to leave this option empty.
  -h, --help             Show this message and exit.Download papers with DOI(s), PMID(s) or TITLE(s)Using option-dor--doito download papers with DOI, option-por--pmidto download papers with PMID,
and option-tor--titleto download papers with titles. You can specify these options for multiple times, and even mix of them.# with a single DOI$scidownldownload--doihttps://doi.org/10.1145/3375633# with multiple DOIs$scidownldownload--doihttps://doi.org/10.1145/3375633--doihttps://doi.org/10.1145/2785956.2787496# with a single PMID$scidownldownload--pmid31395057# with multiple PMIDs$scidownldownload--pmid31395057--pmid24686414# with a single title$scidownldownload--title"ImageNet Classification with Deep Convolutional Neural Networks"# with multiple titles$scidownldownload--title"ImageNet Classification with Deep Convolutional Neural Networks"--title"Aggregated residual transformations for deep neural networks"# with a mix of DOIs and PMIDs$scidownldownload--doihttps://doi.org/10.1145/3375633--pmid31395057--pmid24686414Customize the output location of papersBy default, the downloaded paper is named by the paper's title. With option-oor--out，you can customize the output location of downloaded papers, whcih could be an absolute path or a relative path, and a direcotry or a file path.Output the paepr to a directory:$scidownldownload--pmid31395057--out/absolute/path/of/a/directory/# NOTE that the '/' at the end of the directory path is required, otherwise the last segment will be treated as the filename rather than a directory.$scidownldownload--pmid31395057--out../relative/path/of/a/directory/# The '/' at the end of the directory path is required too.Output the paper with the file path.$scidownldownload--pmid31395057--out/absolute/dir/paper.pdf
$scidownldownload--pmid31395057--out../relative/dir/paper.pdf
$scidownldownload--pmid31395057--outrelative/dir/paper.pdf
$scidownldownload--pmid31395057--outpaper# will be downlaoded as ./paper.pdfNOTEthat if there are more than one papers to be downloaded, the value of the--outoption will always be considered as a directory, rather than a file path.$scidownldownload--pmid31395057--pmid24686414--outpaper# will be downloaded to ./paper/ directory:#  ./paper/<paper-title-1>.pdf#  ./paper/<paper-title-2>.pdfIf some directories in the option are not exist, SciDownl will create them for you :smile:.Use a specific SciHub urlWith option-uor--scihub-url, you could use a specific SciHub url you want, rather than let SciDownl automatically choose one for you from local saved SciHub domains. It's recommended to let SciDownl choose a SciHub url, so you don't need to use this option in normal use.$scidownldownload--pmid31395057--scihub-urlhttp://sci-hub.seModule useYou could usescihub_downloadfunction to download papers.fromscidownlimportscihub_downloadpaper="https://doi.org/10.1145/3375633"paper_type="doi"out="./paper/one_paper.pdf"proxies={'http':'socks5://127.0.0.1:7890'}scihub_download(paper,paper_type=paper_type,out=out,proxies=proxies)More examples could be seen inexamples.LICENSECopyright (c) 2022 tishacy.Licensed under theMIT License.