Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created November 30, 2013 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelcaraciolo/7716030 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/7716030 to your computer and use it in GitHub Desktop.
import json
import urllib
import pymongo
connection = pymongo.Connection('mongodb://localhost', safe = True)
db = connection.reddit
stories = db.stories
reddit_page = urllib.urlopen('http://www.reddit.com/r/Python/.json')
parsed = json.loads(reddit_page.read())
for item in parsed['data']['children']:
stories.insert(item['data'])
print 'Reddit stories ok...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment