我正在尝试从this website下载PDF文件。你知道吗
我是Python新手,目前正在学习Python软件。我下载了urllib和bs4等包。但是,在任何URL中都没有.pdf扩展名。相反,每个都有以下格式:http://www.smv.gob.pe/ConsultasP8/documento.aspx?vidDoc={.....}
。你知道吗
我试过使用汤。全部找到命令。然而,这并不成功。你知道吗
from urllib import request
from bs4 import BeautifulSoup
import re
import os
import urllib
url="http://www.smv.gob.pe/frm_hechosdeImportanciaDia?data=38C2EC33FA106691BB5B5039DACFDF50795D8EC3AF"
response = request.urlopen(url).read()
soup= BeautifulSoup(response, "html.parser")
links = soup.find_all('a', href=re.compile(r'(http://www.smv.gob.pe/ConsultasP8/documento.aspx?)'))
print(links)
这对我很有用:
唯一的区别是我使用
requests
是因为我已经习惯了,并且我为从BeautifulSoup
返回的每个Tag
使用href
属性。你知道吗相关问题 更多 >
编程相关推荐