Python-从URL中删除PDF文件

Python-从URL中删除PDF文件,python,pdf,web-scraping,Python,Pdf,Web Scraping,我想从这个网站上抓取pdf文件 我试过这个代码,但不起作用。有人能告诉我为什么吗 res = requests.get('https://www.sigmaths.net/Reader.php?var=manuels/ph/physique_7b.pdf') with open('C:\\Users\\sioud\\Desktop\\Manuels scolaires TN\\1\\test.pdf', 'wb') as f: f.write(ress.content) 您的url指向一个阅读

我想从这个网站上抓取pdf文件 我试过这个代码,但不起作用。有人能告诉我为什么吗

res = requests.get('https://www.sigmaths.net/Reader.php?var=manuels/ph/physique_7b.pdf')
with open('C:\\Users\\sioud\\Desktop\\Manuels scolaires TN\\1\\test.pdf', 'wb') as f:
f.write(ress.content)
您的url指向一个阅读器
https://www.sigmaths.net/Reader.php?var=manuels/ph/physique_7b.pdf
删除实际pdf的'reader.php?var=
,也可以使用。 查看我的解决方案代码

from urllib.request import urlretrieve
pdfurl = u"https://www.sigmaths.net/manuels/ph/physique_7b.pdf";
urlretrieve(pdfurl, "test.pdf")

您将在名称
test.pdf

下找到所需的pdf下载,其中有什么不起作用?这个代码是做什么的?你期望它做什么?您看到了哪些输出/错误?当您尝试运行代码时,您的代码是否正确格式化(是否在
中使用
块正确缩进
f.write()
)?谢谢您的帮助
from urllib.request import urlretrieve
pdfurl = u"https://www.sigmaths.net/manuels/ph/physique_7b.pdf";
urlretrieve(pdfurl, "test.pdf")