Skip to content

Instantly share code, notes, and snippets.

@fmasanori
Created November 21, 2012 17:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fmasanori/4126471 to your computer and use it in GitHub Desktop.
Save fmasanori/4126471 to your computer and use it in GitHub Desktop.
Python Reddit MongoDB Client
import json
import urllib
import pymongo
con = pymongo.Connection('mongodb://localhost',
safe = True)
db = con.reddit
stories = db.stories
url = 'http://www.reddit.com/r/Python/.json'
resp = urllib.urlopen(url).read()
parsed = json.loads(resp)
for item in parsed['data']['children']:
stories.insert(item['data'])
print ('Reddit stories inserted')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment