Una API no oficial para descargar documentos 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 podría instalarse fácilmente con 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.
Hay 2 modos de actualización que puede especificar con una opción: -m
o --mode
crawl
: [predeterminado] rastreando el sitio web de dominios Scihub en tiempo real (también conocido como, SCIHUB Domain Source) para obtener dominios Scihub disponibles. La URL del sitio web de la fuente de dominio SciHub está configurado en el archivo de configuración global en la sección [scihub.domain.updater.crawl]
con la clave de scihub_domain_source
. Puede usar scidownl config --location
para mostrar la ubicación del archivo de configuración global y editarlo.
; Global config file: global.ini
; ...
[scihub.domain.updater.crawl]
scihub_domain_source = http://tool.yovisun.com/scihub
; ...
Un ejemplo de uso del modo 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
: Genere combinaciones de acuerdo con las reglas de los dominios de Scihub y busque dominios Scihub disponibles. Esto llevará más tiempo que el modo crawl
.
Un ejemplo de uso del modo 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 usa SQLite como la base de datos local para almacenar todos los dominios de Scihub actualizados localmente. Puede enumerar todos los dominios SCIHUB guardados con el domain.list
comando.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 |
+--------------------+----------------+---------------+
Además de la columna de URL fácil de entender, la columna SuccessTimes
se usa para registrar el número de descargas en papel exitosas utilizando esta URL, y la columna FailedTimes
se usa para registrar el número de descargas de papel fallidas usando esta URL. Estas dos columnas se utilizan para calcular la prioridad de elegir un dominio Scihub al descargar documentos.
$ 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.
Uso de la opción -d
o --doi
para descargar documentos con doi, opción -p
o --pmid
para descargar documentos con pmid y opción -t
o --title
para descargar documentos con títulos. Puede especificar estas opciones para varias veces e incluso mezclarlas.
# 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
Por defecto, el documento descargado se nombra por el título del documento. Con la opción -o
o --out
, puede personalizar la ubicación de salida de los documentos descargados, lo que podría ser una ruta absoluta o una ruta relativa, y una ruta directa o una ruta de archivo.
ENTRAR el PAEPR a un directorio:
$ 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.
Emitir el papel con la ruta del archivo.
$ 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
Tenga en cuenta que si hay más de un documento para descargar, el valor de la opción --out
siempre se considerará como un directorio, en lugar de una ruta de archivo.
$ 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 no existen algunos directorios en la opción, Scidownl los creará para usted?
Con la opción -u
o --scihub-url
, puede usar una URL de Scihub específica que desee, en lugar de dejar que Scidownl elija automáticamente uno para usted de los dominios de Scihub guardados locales. Se recomienda dejar que Scidownl elija una URL de Scihub, por lo que no necesita usar esta opción en uso normal.
$ scidownl download --pmid 31395057 --scihub-url http://sci-hub.se
Puede usar la función scihub_download
para descargar documentos.
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 )
Se pueden ver más ejemplos en ejemplos.
Copyright (c) 2022 Tishacy.
Licenciado bajo la licencia del MIT.