4๐
โ
if you use a bad proxy or there are network problems you can try this:
for url in urllist:
retry = 0
while True: # retry request
try:
req = urllib.urlopen(url)
resp_data = req.read() # in call read() network still processing
except Exception as e: # TODO need more detailed handling
if retry > 3: # 3 this is serious problem. exit
raise e
retry += 1 # retry
else:
data = json.loads()
req.close() # not needed
break
๐คsheh
Source:stackexchange.com