I have a list of links to the pdf
files that I need to download.
One of the links:
'https://monentreprise.bj/documentCertificat/get?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg2Njk4MyJ9.xAXlH2CWvVMrs5hwk1rCcEIeKMRFmJAYetrgWJe6qE0'
How can the code be written to directly save the response of that link?
CodePudding user response:
You don't need to use beautiful soup. You can use the request library.
import requests
URL = 'https://monentreprise.bj/documentCertificat/get?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg2Njk4MyJ9.xAXlH2CWvVMrs5hwk1rCcEIeKMRFmJAYetrgWJe6qE0'
r = requests.get(URL)
with open('file_name.pdf', 'wb') as f:
f.write(r.content)