Skip to content

Commit

Permalink
Add Task 2 - work in progress 🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
yeungegs committed Sep 22, 2017
1 parent 9267383 commit 3893f64
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions 0x18-api_advanced/2-recurse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ def recurse(subreddit, hot_list=[], after=""):
"""
url_base = 'http://www.reddit.com/r/'
url_query = '{:s}/hot.json'.format(subreddit)
headers = {'user-agent': 'egsyquest'}
headers = {'user-agent': 'starcraft'}
r = requests.get(url_base + url_query, headers=headers)

if (r.status_code is 302):
print("None")
return
if (r.status_code is 404):
print("None")
return
return None
else:
r = r.json()
for post in r['data']['children']:
hot_list.append(post['data']['title'])

return recurse(subreddit, hot_list, after)

0 comments on commit 3893f64

Please sign in to comment.