Skip to content

Instantly share code, notes, and snippets.

@Roasbeef
Created December 9, 2012 04:12
Show Gist options
  • Save Roasbeef/4243300 to your computer and use it in GitHub Desktop.
Save Roasbeef/4243300 to your computer and use it in GitHub Desktop.
Christmas Reddit Challenge
from collections import Counter
import requests
r = requests.get("http://www.reddit.com/r/christmas/new.json?sort=new&limit=100")
data = json.loads(r.content)
titles = ''.join(submission['data']['title'] for submission in data['data']['children'])
title_words = [word for word in titles.split() if len(title) > 4 and title.isalpha()]
top_count = Counter(title_words).most_common(5) #[(u'Christmas', 52), (u'Santa', 6), (u'about', 4), (u'first', 4), (u'Holiday', 4)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment