Created
May 24, 2020 07:22
-
-
Save R3M4G/fee7845ef241d3b78da32548f087611d to your computer and use it in GitHub Desktop.
A reddit scrapper that prints hot post titles from a subrredit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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