Created
December 9, 2012 04:12
-
-
Save Roasbeef/4243300 to your computer and use it in GitHub Desktop.
Christmas Reddit Challenge
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
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