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


Posted in Python onJuly 09, 2020

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 相关文章推荐
python实现探测socket和web服务示例
Mar 28 Python
Python实现多线程下载文件的代码实例
Jun 01 Python
python设置检查点简单实现代码
Jul 01 Python
Python使用Paramiko模块编写脚本进行远程服务器操作
May 05 Python
利用Anaconda简单安装scrapy框架的方法
Jun 13 Python
在Pycharm terminal中字体大小设置的方法
Jan 16 Python
基于django channel实现websocket的聊天室的方法示例
Apr 11 Python
python定时任务 sched模块用法实例
Nov 04 Python
flask框架渲染Jinja模板与传入模板变量操作详解
Jan 25 Python
python连接mysql数据库并读取数据的实现
Sep 25 Python
python 模块导入问题汇总
Feb 01 Python
Pytorch - TORCH.NN.INIT 参数初始化的操作
Feb 27 Python
Python scrapy爬取小说代码案例详解
Jul 09 #Python
使用Python实现微信拍一拍功能的思路代码
Jul 09 #Python
pytorch 多分类问题,计算百分比操作
Jul 09 #Python
详解Python 循环嵌套
Jul 09 #Python
keras分类之二分类实例(Cat and dog)
Jul 09 #Python
python中tkinter窗口位置\坐标\大小等实现示例
Jul 09 #Python
Python2.x与3​​.x版本有哪些区别
Jul 09 #Python
You might like
PHP代码保护--Zend Guard的使用详解
2013/06/03 PHP
php之CodeIgniter学习笔记
2013/06/17 PHP
php实现的zip文件内容比较类
2014/09/24 PHP
PHP实现指定字段的多维数组排序函数分享
2015/03/09 PHP
js实现的网站首页随机公告随机公告
2007/03/14 Javascript
基于jquery的大众点评,分类导航实现代码
2011/08/23 Javascript
禁止你的左键复制实用技巧
2013/01/04 Javascript
javascript-简单的计算器实现步骤分解(附图)
2013/05/30 Javascript
js中的布尔运算符使用介绍
2013/11/20 Javascript
JS匀速运动演示示例代码
2013/11/26 Javascript
JavaScript实现图片DIV竖向滑动的方法
2015/04/25 Javascript
原生js实现吸顶效果
2017/03/13 Javascript
使用ionic(选项卡栏tab) icon(图标) ionic上拉菜单(ActionSheet) 实现通讯录界面切换实例代码
2017/10/20 Javascript
Vue.js通用应用框架-Nuxt.js的上手教程
2017/12/25 Javascript
解决Vue项目中tff报错的问题
2020/10/21 Javascript
[34:08]2018DOTA2亚洲邀请赛3月29日 小组赛B组 VP VS EG
2018/03/30 DOTA
[55:18]Liquid vs Chaos 2019国际邀请赛小组赛 BO2 第一场 8.15
2019/08/16 DOTA
Python pass详细介绍及实例代码
2016/11/24 Python
Apache如何部署django项目
2017/05/21 Python
python字典操作实例详解
2017/11/16 Python
Python简单生成随机姓名的方法示例
2017/12/27 Python
使用python获取csv文本的某行或某列数据的实例
2018/04/03 Python
pandas 将索引值相加的方法
2018/11/15 Python
Python实用工具FuckIt.py介绍
2019/07/02 Python
基于Python解密仿射密码
2019/10/21 Python
python 密码学示例——凯撒密码的实现
2020/09/21 Python
一款纯css3实现的鼠标经过按钮特效教程
2014/11/09 HTML / CSS
谈谈对css属性box-sizing的了解
2017/01/04 HTML / CSS
Glamest意大利:女性在线奢侈品零售店
2019/04/28 全球购物
运动会解说词200字
2014/02/06 职场文书
企业精细化管理实施方案
2014/03/23 职场文书
学习“七一”讲话精神体会
2014/07/08 职场文书
中学生运动会新闻稿
2014/09/24 职场文书
批评与自我批评总结
2014/10/17 职场文书
春节慰问信范文
2015/02/15 职场文书
2015年妇产科工作总结
2015/05/18 职场文书