当前位置:首页 » python web » 正文

利用python下载scihub成文献为PDF操作

看: 1166次  时间:2020-08-29  分类 : python web

scihub是科研利器,这就不多说了,白嫖文献的法门,一般采用的是网页或者桌面程序,一般都会跳转到网页进行加载出文献,但是这很不方便,毕竟全手动,这里无意中看到一个写好的pip工具scihub2pdf ,于是试一下它手动威力,如果这能够成功,也就是我们以后如果想批量下载也是没问题的。

1.首先我们得安装它:

pip install scihub2pdf

2.紧接着安装npm和phantomjs,因为这个代码里面使用了phantomjs

yum install npm

切换到国内源,威力网速给力,npm是nodejs的仓库,我们类比成python的pip即可

npm config set registry https://registry.npm.taobao.org

安装 phantomjs

npm install -g phantomjs

如果顺利成功的话,就可以试一下这个工具了

3.scihub2pdf的使用

先来看一下使用帮助

[root@VM_0_9_centos ~]# scihub2pdf -h
usage: scihub2pdf [-h] [--input INPUTFILE] [--title] [--uselibgen]
   [--location LOCATION] [--txt]

 SciHub to PDF
 ----------------------------------------------------
 Downloads pdfs via a DOI number, article title
 or a bibtex file, using the database of libgen(sci-hub).

 Given a bibtex file

 $ scihub2pdf -i input.bib

 Given a DOI number...

 $ scihub2pdf 10.1038/s41524-017-0032-0

 Given a title...

 $ scihub2pdf --title An useful paper

 Arxiv...

 $ scihub2pdf arxiv:0901.2686

 $ scihub2pdf --title arxiv:Periodic table for topological insulators

 ## Download from list of items

 Given a text file like

10.1038/s41524-017-0032-0 10.1063/1.3149495 .....

 download all pdf's

$ scihub2pdf -i dois.txt --txt

 Given a text file like

Some Title 1 Some Title 2 .....

 download all pdf's

$ scihub2pdf -i titles.txt --txt --title

 Given a text file like

arXiv:1708.06891 arXiv:1708.06071 arXiv:1708.05948 ..... ``` download all pdf's

 $ scihub2pdf -i arxiv_ids.txt --txt

@author: Bruno Messias @email: messias.physics@gmail.com @telegram: @brunomessias @github: https://github.com/bibcure/sci2pdf optional arguments: -h, --help show this help message and exit --input INPUTFILE, -i INPUTFILE bibtex input file --title, -t download from title --uselibgen Use libgen.io instead sci-hub. --location LOCATION, -l LOCATION folder, ex: -l 'folder/' --txt Just create a file with DOI's or titles ```

我们可以粗略看到,这个不仅仅可以doi还可批量的doi写在一个文件里,进行批量下载,更牛的是可以直接使用论文标题进行下载,这就理解为啥这里面需要想依赖phantomjs了,这玩意就是爬虫用的。

我们来试一下:

[root@VM_0_9_centos ~]# scihub2pdf 10.1063/1.4991232

注意的是,这里需要修改源码,因为用的链接不对,我们应该使用http://sci-hub.tw/而不是http://sci-hub.cc,在源码(我自己的是在vim /opt/AN/lib/python3.7/site-packages/scihub2pdf/download.py修改的,根据自己pip安装的路径进行调整)的download.py下就可找到进行修改,因为cc这个链接已经用不了的。

还可以下载arxiv上的论文,比如

[root@VM_0_9_centos ~]# scihub2pdf arxiv:2003.02355

下载时间都是有点慢的,要等一会才能成功,因为都是访问的国外的网站

以上这篇利用python下载scihub成文献为PDF操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持python博客。

<< 上一篇 下一篇 >>

搜索

推荐资源

  Powered By python教程网   鲁ICP备18013710号
python博客 - 小白学python最友好的网站!