1.发生5xx错误时重复请求方法
def reqURL(url,num=2):
try:
html=urllib2.urlopen(url).read()
except urllib2.URLError as e:
html=None
if num >0:
if hasattr(e,'code') and 500 <=e.code <600:
return reqURL(url,num-1)
1.发生5xx错误时重复请求方法
def reqURL(url,num=2):
try:
html=urllib2.urlopen(url).read()
except urllib2.URLError as e:
html=None
if num >0:
if hasattr(e,'code') and 500 <=e.code <600:
return reqURL(url,num-1)