Skip to content

Instantly share code, notes, and snippets.

View mraakashshah's full-sized avatar

Aakash Shah mraakashshah

View GitHub Profile
@mraakashshah
mraakashshah / reddit2db.py
Created September 11, 2019 04:21
reddit posts -> sqlite3
import sqlite3
import time
import json
import urllib2
def get_submissions():
url="http://www.reddit.com/r/all/new/.json" #URL of the page that we want to fetch
headers = { 'User-Agent' : 'fetching new submissions script' } # our script "identifier"
req = urllib2.Request(url, None, headers) # We create new request here to open the url with above set headers
data = urllib2.urlopen(req).read() # Open url and make data variable equal whatever we get