利用python下載scihub成文獻(xiàn)為PDF操作
scihub是科研利器,這就不多說(shuō)了,白嫖文獻(xiàn)的法門,一般采用的是網(wǎng)頁(yè)或者桌面程序,一般都會(huì)跳轉(zhuǎn)到網(wǎng)頁(yè)進(jìn)行加載出文獻(xiàn),但是這很不方便,畢竟全手動(dòng),這里無(wú)意中看到一個(gè)寫好的pip工具scihub2pdf ,于是試一下它手動(dòng)威力,如果這能夠成功,也就是我們以后如果想批量下載也是沒(méi)問(wèn)題的。
1.首先我們得安裝它:
pip install scihub2pdf
2.緊接著安裝npm和phantomjs,因?yàn)檫@個(gè)代碼里面使用了phantomjs
yum install npm
切換到國(guó)內(nèi)源,威力網(wǎng)速給力,npm是nodejs的倉(cāng)庫(kù),我們類比成python的pip即可
npm config set registry https://registry.npm.taobao.org
安裝 phantomjs
npm install -g phantomjs
如果順利成功的話,就可以試一下這個(gè)工具了
3.scihub2pdf的使用
先來(lái)看一下使用幫助
[root@VM_0_9_centos ~]# scihub2pdf -husage: 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/sci2pdfoptional 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
我們可以粗略看到,這個(gè)不僅僅可以doi還可批量的doi寫在一個(gè)文件里,進(jìn)行批量下載,更牛的是可以直接使用論文標(biāo)題進(jìn)行下載,這就理解為啥這里面需要想依賴phantomjs了,這玩意就是爬蟲(chóng)用的。
我們來(lái)試一下:
[root@VM_0_9_centos ~]# scihub2pdf 10.1063/1.4991232
注意的是,這里需要修改源碼,因?yàn)橛玫逆溄硬粚?duì),我們應(yīng)該使用http://sci-hub.tw/而不是http://sci-hub.cc,在源碼(我自己的是在vim /opt/AN/lib/python3.7/site-packages/scihub2pdf/download.py修改的,根據(jù)自己pip安裝的路徑進(jìn)行調(diào)整)的download.py下就可找到進(jìn)行修改,因?yàn)閏c這個(gè)鏈接已經(jīng)用不了的。
還可以下載arxiv上的論文,比如
[root@VM_0_9_centos ~]# scihub2pdf arxiv:2003.02355
下載時(shí)間都是有點(diǎn)慢的,要等一會(huì)才能成功,因?yàn)槎际窃L問(wèn)的國(guó)外的網(wǎng)站
以上這篇利用python下載scihub成文獻(xiàn)為PDF操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. JavaScript中常見(jiàn)的幾種獲取元素的方式2. Xml簡(jiǎn)介_(kāi)動(dòng)力節(jié)點(diǎn)Java學(xué)院整理3. phpstudy apache開(kāi)啟ssi使用詳解4. ASP.NET MVC使用異步Action的方法5. ajax實(shí)現(xiàn)頁(yè)面的局部加載6. jsp實(shí)現(xiàn)登錄驗(yàn)證的過(guò)濾器7. jsp文件下載功能實(shí)現(xiàn)代碼8. uni-app結(jié)合.NET 7實(shí)現(xiàn)微信小程序訂閱消息推送9. 爬取今日頭條Ajax請(qǐng)求10. 利用ajax+php實(shí)現(xiàn)商品價(jià)格計(jì)算
