Skip to content

Instantly share code, notes, and snippets.

@R3M4G
Created May 24, 2020 07:22
Show Gist options
  • Save R3M4G/fee7845ef241d3b78da32548f087611d to your computer and use it in GitHub Desktop.
Save R3M4G/fee7845ef241d3b78da32548f087611d to your computer and use it in GitHub Desktop.
A reddit scrapper that prints hot post titles from a subrredit
#! /usr/bin/env python3
import json
import requests
subr = input('Enter the subreddit:')
url = 'https://reddit.com/r/{}.json'.format(subr)
headers = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0'}
r = requests.get(url, headers=headers)
for post in r.json()['data']['children']:
print('')
print(post['data']['title'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment