Remove ad-hoc response saving from code, create a debug setting for fetch_url
This commit is contained in:
@@ -83,7 +83,7 @@ def request_comments(ctoken, replies=False):
|
||||
url = base_url + ctoken.replace("=", "%3D") + "&pbj=1"
|
||||
|
||||
for i in range(0,8): # don't retry more than 8 times
|
||||
content = util.fetch_url(url, headers=mobile_headers, report_text="Retrieved comments")
|
||||
content = util.fetch_url(url, headers=mobile_headers, report_text="Retrieved comments", debug_name='request_comments')
|
||||
if content[0:4] == b")]}'": # random closing characters included at beginning of response for some reason
|
||||
content = content[4:]
|
||||
elif content[0:10] == b'\n<!DOCTYPE': # occasionally returns html instead of json for no reason
|
||||
@@ -91,8 +91,6 @@ def request_comments(ctoken, replies=False):
|
||||
print("got <!DOCTYPE>, retrying")
|
||||
continue
|
||||
break
|
||||
'''with open('debug/comments_debug', 'wb') as f:
|
||||
f.write(content)'''
|
||||
return content
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user