Skip to content
Advertisement

Python – Scraping a PDF file from a URL

I want to scrape pdf files from this site https://www.sigmaths.net/Reader.php?var=manuels/ph/physique_pilote_7b.pdf I tried this code for that but it doesn’t work. Can anybody tell me why, please?

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)

Advertisement

Answer

res = requests.get('https://www.sigmaths.net/manuels/ph/physique_7b.pdf',stream=True)
with open('test.pdf', 'wb') as f:
    f.write(res.content)

your url is pointing to a reader https://www.sigmaths.net/Reader.php?var=manuels/ph/physique_7b.pdf, remove the 'reader.php?var= for the actual pdf

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement