오류가 발생했을 때이 함수를 다시 시도하는 방법, 최대 세 번 재시도?루프 제한 시간 동안
def crawl(url):
while True:
try:
data = os.popen('wget -qO- -T10 --tries=1 --header="Accept: text/html" --user-agent="User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11 " %s'% url).read()
return data
except Exception, e:
print e
pass
crawl("http://aaa.com")
내에서 3 회 반복하는 방법 while
루프를 다시 시도 하시겠습니까?
좋은 해결책. 사소한 피드백 지점 :'expect'는'except'이어야합니다 :) –
물론 :) –