Skip to content

Commit 538b4bc

Browse files
committed
Add MAX_TRIES to get html
1 parent 2cfa6ea commit 538b4bc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ACedIt/util.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,15 @@ def get_html(url):
379379
"""
380380
Utility function get the html content of an url
381381
"""
382+
MAX_TRIES = 3
382383
try:
383-
r = rq.get(url)
384+
for try_count in range(MAX_TRIES):
385+
r = rq.get(url)
386+
if r.status_code == 200:
387+
break
388+
if try_count >= MAX_TRIES:
389+
print 'Could not fetch content. Please try again.'
390+
sys.exit(0)
384391
except Exception as e:
385392
print 'Please check your internet connection and try again.'
386393
sys.exit(0)

0 commit comments

Comments
 (0)