samedi 6 décembre 2014

Urllib and saving multiple urls to different filenames


Vote count:

0




I have tried searching the urllib documentation, learnpython subreddit and here. Perhaps I am searching irrelevant keywords.


I am looking to download multiple url images to the same directory, although with different file names. How could I achieve this? Provided is the appropriate excerpt.Thank you for your time!



def downloaddata():

urls = ["url1.gif",""url2.gif", "url3.gif","url4.gif"]
filepaths = ["samepath/1.gif","samepath/2.gif","samepath/3.gif","samepath/4.gif"]

for url in urls:
try:
image = urllib.URLopener()
image.retrieve(url, filepaths)
break
except ValueError:
pass


asked 46 secs ago







Urllib and saving multiple urls to different filenames

Aucun commentaire:

Enregistrer un commentaire