forked from ideoforms/python-twitter-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter-trends.py
executable file
·35 lines (27 loc) · 1.27 KB
/
twitter-trends.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python
#-----------------------------------------------------------------------
# twitter-trends
# - lists the current global trending topics
#-----------------------------------------------------------------------
from twitter import *
#-----------------------------------------------------------------------
# load our API credentials
#-----------------------------------------------------------------------
config = {}
execfile("config.py", config)
#-----------------------------------------------------------------------
# create twitter API object
#-----------------------------------------------------------------------
twitter = Twitter(
auth = OAuth(config["access_key"], config["access_secret"], config["consumer_key"], config["consumer_secret"]))
#-----------------------------------------------------------------------
# retrieve global trends.
# other localised trends can be specified by looking up WOE IDs:
# http://developer.yahoo.com/geo/geoplanet/
# twitter API docs: https://dev.twitter.com/rest/reference/get/trends/place
#-----------------------------------------------------------------------
results = twitter.trends.place(_id = 23424975)
print "UK Trends"
for location in results:
for trend in location["trends"]:
print " - %s" % trend["name"]