- Read from the input file
- Perform recursive download for all files
- Try catch handled errors and downloaded file successfully
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
#Read file tab spaced | |
f = open("facescrub_actresses.txt",'r') | |
readlines = f.readlines() | |
i = 1 | |
title = "female" | |
for line in readlines: | |
name = title + str(i) + ".jpg" | |
i = i+1 | |
#Download only 300 images | |
if(i==300): | |
break | |
values = line.split('\t') | |
print('Imagepath-',values[3]) | |
try: | |
#Download Image to directory | |
urllib.request.urlretrieve(values[3],name) | |
except: | |
print("Error for",values[3]) |
No comments:
Post a Comment