Une API non officielle pour le téléchargement des articles de SciHub.
# Download with a DOI and filenmae is the paper's title.
$ scidownl download --doi https://doi.org/10.1145/3375633
# Download with a PMID and a user-defined filepath
$ scidownl download --pmid 31395057 --out ./paper/paper-1.pdf
# Download with a title
$ scidownl download --title " ImageNet Classification with Deep Convolutional Neural Networks " --out ./paper/paper-1.pdf
# Download with a proxy: SCHEME=PROXY_ADDRESS
$ scidownl download --pmid 31395057 --out ./paper/paper-1.pdf --proxy http=socks5://127.0.0.1:7890
Scidownl pourrait être facilement installé avec PIP.
$ pip3 install -U scidownl
$ git clone https://github.com/Tishacy/SciDownl.git
$ cd Scidownl && python3 setup.py install
$ scidownl -h
Usage: scidownl [OPTIONS] COMMAND [ARGS]...
Command line tool to download pdfs from Scihub.
Options:
-h, --help Show this message and exit.
Commands:
config Get global configs.
domain.list List available SciHub domains in local db.
domain.update Update available SciHub domains and save them to local db.
download Download paper(s) by DOI or PMID.
$ scidownl domain.update --help
Usage: scidownl domain.update [OPTIONS]
Update available SciHub domains and save them to local db.
Options:
-m, --mode TEXT update mode, could be ' crawl ' or ' search ' , default mode is
' crawl ' .
-h, --help Show this message and exit.
Il existe 2 modes de mise à jour que vous pouvez spécifier avec une option: -m
ou --mode
crawl
: [par défaut] rampant sur le site Web de domaines SciHub mis à jour en temps réel (aka, source de domaine SciHub) pour obtenir des domaines SciHub disponibles. L'URL du site Web SciHub Domain Source est configurée dans le fichier de configuration global dans la section [scihub.domain.updater.crawl]
avec la clé de scihub_domain_source
. Vous pouvez utiliser scidownl config --location
pour afficher l'emplacement du fichier de configuration global et le modifier.
; Global config file: global.ini
; ...
[scihub.domain.updater.crawl]
scihub_domain_source = http://tool.yovisun.com/scihub
; ...
Un exemple d'utilisation du mode crawl
:
$ scidownl domain.update --mode crawl
[INFO] | 2022/03/07 21:07:50 | Found 6 valid SciHub domains in total: [ ' 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/07 21:07:50 | Saved 6 SciHub domains to local db.
search
: générer des combinaisons selon les règles des domaines SciHub et rechercher les domaines SciHub disponibles. Cela prendra plus de temps que le mode crawl
.
Un exemple d'utilisation du mode search
:
$ scidownl domain.update --mode search
[INFO] | 2022/03/07 21:08:44 | # Search valid SciHub domains from 1352 urls
[INFO] | 2022/03/07 21:08:48 | # Found a SciHub domain url: https://sci-hub.ru
[INFO] | 2022/03/07 21:08:48 | # Found a SciHub domain url: https://sci-hub.st
...
[INFO] | 2022/03/07 21:09:04 | Found 6 valid SciHub domains in total: [ ' https://sci-hub.ru ' , ' https://sci-hub.st ' , ...]
[INFO] | 2022/03/07 21:09:04 | Saved 6 SciHub domains to local db.
Scidownl utilise SQLite comme base de données locale pour stocker tous les domaines SciHub mis à jour localement. Vous pouvez répertorier tous les domaines SciHub enregistrés avec le domain.list
de commande.List.
$ scidownl domain.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 |
+--------------------+----------------+---------------+
En plus de la colonne d'URL facile à comprendre, la colonne SuccessTimes
est utilisée pour enregistrer le nombre de téléchargements de papier réussi à l'aide de cette URL, et la colonne FailedTimes
est utilisée pour enregistrer le nombre de téléchargements de papier défaillants à l'aide de cette URL. Ces deux colonnes sont utilisées pour calculer la priorité du choix d'un domaine SciHub lors du téléchargement des papiers.
$ 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.
Utilisation de l'option -d
ou --doi
pour télécharger des articles avec DOI, Option -p
ou --pmid
pour télécharger des papiers avec PMID et Option -t
ou --title
pour télécharger des articles avec des titres. Vous pouvez spécifier ces options plusieurs fois, et même en mélangez.
# with a single DOI
$ scidownl download --doi https://doi.org/10.1145/3375633
# with multiple DOIs
$ scidownl download --doi https://doi.org/10.1145/3375633 --doi https://doi.org/10.1145/2785956.2787496
# with a single PMID
$ scidownl download --pmid 31395057
# with multiple PMIDs
$ scidownl download --pmid 31395057 --pmid 24686414
# with a single title
$ scidownl download --title " ImageNet Classification with Deep Convolutional Neural Networks "
# with multiple titles
$ scidownl download --title " ImageNet Classification with Deep Convolutional Neural Networks " --title " Aggregated residual transformations for deep neural networks "
# with a mix of DOIs and PMIDs
$ scidownl download --doi https://doi.org/10.1145/3375633 --pmid 31395057 --pmid 24686414
Par défaut, le papier téléchargé est nommé par le titre du journal. Avec l'option -o
ou --out
, vous pouvez personnaliser l'emplacement de sortie des articles téléchargés, whcih pourrait être un chemin absolu ou un chemin relatif, et une direction ou un chemin de fichier.
Sortie du Paepr vers un répertoire:
$ scidownl download --pmid 31395057 --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.
$ scidownl download --pmid 31395057 --out ../relative/path/of/a/directory/
# The '/' at the end of the directory path is required too.
Sortez le papier avec le chemin du fichier.
$ scidownl download --pmid 31395057 --out /absolute/dir/paper.pdf
$ scidownl download --pmid 31395057 --out ../relative/dir/paper.pdf
$ scidownl download --pmid 31395057 --out relative/dir/paper.pdf
$ scidownl download --pmid 31395057 --out paper # will be downlaoded as ./paper.pdf
Notez que s'il y a plus d'un article à télécharger, la valeur de l'option --out
sera toujours considérée comme un répertoire plutôt que comme un chemin de fichier.
$ scidownl download --pmid 31395057 --pmid 24686414 --out paper
# will be downloaded to ./paper/ directory:
# ./paper/<paper-title-1>.pdf
# ./paper/<paper-title-2>.pdf
Si certains répertoires dans l'option n'existent pas, Scidownl les créera pour vous ?.
Avec l'option -u
ou --scihub-url
, vous pouvez utiliser une URL SciHub spécifique que vous souhaitez, plutôt que de laisser ScidownL en choisir automatiquement un pour vous dans les domaines SciHub enregistrés locaux. Il est recommandé de laisser Scidownl choisir une URL SciHub, vous n'avez donc pas besoin d'utiliser cette option en usage normal.
$ scidownl download --pmid 31395057 --scihub-url http://sci-hub.se
Vous pouvez utiliser la fonction scihub_download
pour télécharger des articles.
from scidownl import scihub_download
paper = "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 )
Plus d'exemples ont pu être vus dans des exemples.
Copyright (C) 2022 Tishacy.
Licencié sous la licence du MIT.