1
Schreiben Pfad ist:Python Anfrage werfen Fehler IOError: [Errno 22] ungültig Modus ('wb') oder Dateiname:
write_path = 'C:\Users\hgdht\Desktop\Downloader_Automation'
ich folgende Fehlermeldung erhalten:
IOError: [Errno 22] invalid mode ('wb') or filename: 'ciarb_annual_review_2011_c
.pdf?sfvrsn=2'
Hier die ist code:
import os
import csv
import requests
write_path = r'C:\Users\hgdht\Desktop\Downloader_Automation' # ASSUMING THAT FOLDER EXISTS!
with open('final.csv', 'r') as csvfile:
spamreader = csv.reader(csvfile)
for link in spamreader:
print('-'*72)
print(link)
pdf_file = link[0].split('/')[-1]
with open(os.path.join(write_path, pdf_file), 'wb') as pdf:
try:
# Try to request PDF from URL
print('TRYING {}...'.format(link[0]))
a = requests.get(link[0], stream=True)
for block in a.iter_content(512):
if not block:
break
pdf.write(block)
print('OK.')
except requests.exceptions.RequestException as e: # This will catch ONLY Requests exceptions
print('REQUESTS ERROR:')
print(e) # This should tell you more details about the error
Geben Sie bitte Ihren Code ein. – itzMEonTV
haben Sie diesen 'write_path = 'C: \\ Benutzer \\ hgdht \\ Desktop \\ Downloader_Automation \" versucht? Haben Sie 'ciarb_annual_review_2011_c.pdf? sfvrsn = 2''-Datei auf Ihrem Computer? Wenn ja, an welchem Ort? –
'?' Ist ein ungültiges Zeichen in einem Dateinamen unter Windows –