this code is built to download images from links in a column called "link" in CSV file and replace it with the name in another column called "name" but the code stopped working when he is facing a non-English character, I want the code to work also with non-english character
here is the code
import urllib.request
import csv
import os
with open('booklogo.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print(row)
if row["link"] != '' and row["title"] != '':
name, ext = os.path.splitext(row['link'])
if ext == '':
ext = ".png"
title_filename = f"{row['title']}{ext}".replace('/', '-')
urllib.request.urlretrieve(row['link'], title_filename)
here is the error
OSError Input In [5], in <cell line: 5>() 13 ext = ".png" 14 title_filename = f"{row['title']}{ext}".replace('/', '-') ---> 15 urllib.request.urlretrieve(row['link'], title_filename) File ~\anaconda3\lib\urllib\request.py:249, in urlretrieve(url, filename, reporthook, data) 247 # Handle temporary file setup. 248 if filename: --> 249 tfp = open(filename, 'wb') 250 else: 251 tfp = tempfile.NamedTemporaryFile(delete=False) OSError: [Errno 22] Invalid argument: 'Albert ?eská republika.png