python自动下载pdf_自动下载多个pdf文件中的所有链接(pdf)

{1正在尝试从网站下载期刊(^ m)。我运行了一些东西来获取这个页面上的所有PDF文件。但是这些PDF中有链接链接到另一个PDF。在

我想从所有的PDF链接得到终端文章。在import os

import requests

from urllib.parse import urljoin

from bs4 import BeautifulSoup

url = "http://cis-ca.org/islamscience1.php"

#If there is no such folder, the script will create one automatically

folder_location = r'webscraping'

if not os.path.exists(folder_location):os.mkdir(folder_location)

response = requests.get(url)

soup= BeautifulSoup(response.text, "html.parser")

for link in soup.select("a[href$='.pdf']"):

#Name the pdf files using the last portion of each link which are unique in this case

filename = os.path.join(folder_location,link['href'].split('/')[-1])

with open(filename, 'wb') as f:

f.write(requests.get(urljoin(url,link['href'])).content)

我想把这些PDF里面的文章链接起来。

提前谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值