I have a .csv file that contains links to some PDF files. When pressed, these links automatically start to download the file (one example of such link would be https://rei.gov.ro/teza-doctorat-document/82405e69f7a7a04f8-TEZA-DOCTORAT-AGNES-GAZDAC-semnat-.pdf).
My attempts of building a python script to download all of them return 404. I want to understand why this is happening and to see if I can find a solution to this problem
csv = 'links.csv'
df = pd.read_csv(csv)
def download_pdf(url, file_name):
try:
response = requests.get(url)
response.raise_for_status()
with open(file_name, 'wb') as file:
file.write(response.content)
except requests.exceptions.RequestException as e:
print(e)
for i, row in df.iterrows():
url = row['Link']
file_name = f'file_{i + 1}.pdf'
download_pdf(url, file_name)