# your code goes hereimport sys
import urllib.request
import os.path
def dload(url,a):
req=urllib.request.Request(url)
try:
img=urllib.request.urlopen(req)
localfile=open(os.path.basename(a),"wb")
localfile.write(img.read())
img.close()
localfile.close()
except urllib.error.URLError as e:
print(a)
print(e.reason)
f=open("urls.txt","r")
a=0
for line in f:
a=a+1
string=str(a)
fname="pic"+string.zfill(3)+".jpg"
dname=os.getcwd()
fpath=os.path.join(dname,fname)
print("start "+fpath)
print(os.path.isfile(a))
if os.path.isfile(a)!= True :
dload(line,fpath)
print("end "+fpath)
IyB5b3VyIGNvZGUgZ29lcyBoZXJlaW1wb3J0IHN5cwppbXBvcnQgdXJsbGliLnJlcXVlc3QKaW1wb3J0IG9zLnBhdGgKCgpkZWYgZGxvYWQodXJsLGEpOgogICAgcmVxPXVybGxpYi5yZXF1ZXN0LlJlcXVlc3QodXJsKQogICAgdHJ5OgogICAgICAgIGltZz11cmxsaWIucmVxdWVzdC51cmxvcGVuKHJlcSkKICAgICAgICBsb2NhbGZpbGU9b3Blbihvcy5wYXRoLmJhc2VuYW1lKGEpLCJ3YiIpCiAgICAgICAgbG9jYWxmaWxlLndyaXRlKGltZy5yZWFkKCkpCiAgICAgICAgaW1nLmNsb3NlKCkKICAgICAgICBsb2NhbGZpbGUuY2xvc2UoKQogICAgZXhjZXB0IHVybGxpYi5lcnJvci5VUkxFcnJvciBhcyBlOgogICAgICAgIHByaW50KGEpCiAgICAgICAgcHJpbnQoZS5yZWFzb24pCgpmPW9wZW4oInVybHMudHh0IiwiciIpCmE9MApmb3IgbGluZSBpbiBmOgogICBhPWErMQogICBzdHJpbmc9c3RyKGEpCiAgIGZuYW1lPSJwaWMiK3N0cmluZy56ZmlsbCgzKSsiLmpwZyIKICAgZG5hbWU9b3MuZ2V0Y3dkKCkKICAgZnBhdGg9b3MucGF0aC5qb2luKGRuYW1lLGZuYW1lKQoKICAgcHJpbnQoInN0YXJ0ICIrZnBhdGgpCiAgIHByaW50KG9zLnBhdGguaXNmaWxlKGEpKQogICBpZiBvcy5wYXRoLmlzZmlsZShhKSE9IFRydWUgOgogICAgICAgZGxvYWQobGluZSxmcGF0aCkKICAgICAgIHByaW50KCJlbmQgIitmcGF0aCkKCg==