from urllib.request import urlretrieve
url = (
"https://online.personalcarecouncil.org/ctfa-static/online/lists/cir-pdfs/PRS572.pdf"
)
filename = "PDF File.pdf"
path, headers = urlretrieve(url, filename)
for name, value in headers.items():
print(name, value)
print(f"Downloaded file {path}")
However, when the file that I downloaded is only 1KB hence I cannot open nor read it, and it’s far from the actual PDF file when I click on the link! How can I fix this?
Are you sure the file is not just 1KB in size? I see the file contains some javascript and doesn’t seem to contain more than 240bytes which is just 1KB. Double check that is the right file.
That is the file that I want. When I went to the link directly, I had no problems with the file. But when I tried downloading it from my code, this happens.
Hi @chenphilip14, it appears that this resource requires authentication; if you open the downloaded file in a plain text editor, you’ll see some JS that would just redirect to the home / login page: