Skip to content

Instantly share code, notes, and snippets.

@odunola499
Last active September 10, 2022 13:41
Show Gist options
  • Save odunola499/4262f076f37e5f2882a9cf9f42273577 to your computer and use it in GitHub Desktop.
Save odunola499/4262f076f37e5f2882a9cf9f42273577 to your computer and use it in GitHub Desktop.
while True:
res = requests.get(f'{api}/r/wallstreetbets/new', headers = headers,
params = {'limit': '100', 'after':df['name'].iloc[len(df) - 1]})
if len(res.json()['data']['children']) == 0 :
break
for post in res.json()['data']['children']:
df = df.append({
'name':post['data']['name'],
'created_utc': post['data']['created_utc'],
'subreddit':post['data']['subreddit'],
'title':post['data']['title'],
'selftext':post['data']['selftext'],
'upvote_ratio':post['data']['upvote_ratio'],
'ups':post['data']['ups'],
'downs':post['data']['downs'],
'score':post['data']['score']
}, ignore_index = True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment