python下载论文pdf_Python实现一个论文下载器

该博客介绍了如何使用Python编写一个简单的论文下载器。通过发送POST请求到sci-hub.ren网站,搜索并获取论文的PDF链接。
摘要由CSDN通过智能技术生成

def search_article(artName):

‘’’

搜索论文

---------------

输入:论文名

---------------

输出:搜索结果(如果没有返回"",否则返回PDF链接)

‘’’

url = ‘https://www.sci-hub.ren/’

headers = {‘User-Agent’:‘Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0’,

‘Accept’:‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8’,

‘Accept-Language’:‘zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2’,

‘Accept-Encoding’:‘gzip, deflate, br’,

‘Content-Type’:‘application/x-www-form-urlencoded’,

‘Content-Length’:‘123’,

‘Origin’:‘https://www.sci-hub.ren’,

‘Connection’:‘keep-alive’,

‘Upgrade-Insecure-Requests’:‘1’}

data = {‘sci-hub-plugin-check’:’’,

‘request’:artName}

res = requests.post(url, headers=headers, data=data)http://www.yezidianjing.com/

html = res.text

soup = BeautifulSoup(html, ‘html.parser’)

iframe = soup.find(id=‘pdf’)

if iframe == None: # 未找到相应文章

return ‘’

else:

downUrl = iframe[‘src’]

if ‘http’ not in downUrl:

downUrl = ‘https:’+downUrl

return downUrl

原文链接:https://blog.csdn.net/yezikeji/article/details/112764408

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值