I've created a script to download a file from this link. The script most of the times download the file parially and as a result I can't see the content of that file. How can I force the script to download the file completely?
Here is the script I'm trying with:
import os
import requests
link = 'http://www.sidney.ca/Assets/Active+Development+Applications/2021/9633_Third_Street_Plans.pdf'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
}
res = requests.get(link,headers=headers,stream=True)
with open('Third_Street_Plans.pdf', 'wb') as f:
for chunk in res.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)