Last active
December 11, 2015 21:59
-
-
Save fmasanori/4666650 to your computer and use it in GitHub Desktop.
Python 3.x Twitter Trending Topics
This file contains hidden or 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
# | |
# API DEPRECATED AT JUNE 2013 | |
# https://dev.twitter.com/docs/faq#17750 | |
# | |
import urllib.request | |
import json | |
def trend_topics(): | |
url = 'https://api.twitter.com/1/trends/1.json' | |
resp = urllib.request.urlopen(url).read() | |
data = json.loads(resp.decode('utf-8')) | |
return data | |
for result in trend_topics(): | |
for trend in result['trends']: | |
print (trend['name']) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment