For example, I want to download the pictures to the folder named pictures. How can I do this with urllib request
import os
import urllib.request
try:
klasor_yarat = os.mkdir("resimler")
except:
pass
say = 1
for i in resim_listesi:
urllib.request.urlretrieve(i,str(klasor_yarat)+"\"resim" +str(say)+ ".jpg")
say+=1
There seem to be several problems here:
"\"resim"
is not the correct way to put a '/'
in the string. You have to use "/"
or "\\"
.str(klasor_yarat)
returns "None"
.".jpg"
to the image retrieved. What if the image is a different extension?resim_listesi
is an iterable. I can't know that because it's not defined in the code given.Anyway, this should probably work.
import os
import urllib.request
try:
klasor_yarat = os.mkdir("resimler")
except:
pass
say = 1
for i in resim_listesi:
urllib.request.urlretrieve(i,"resimler/resim" +str(say)+ ".jpg")
say+=1