-
Notifications
You must be signed in to change notification settings - Fork 323
/
twitter-trends.py
executable file
·38 lines (30 loc) · 1.35 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
36
37
38
#!/usr/bin/env python3
#-----------------------------------------------------------------------
# twitter-trends
# - lists the current global trending topics
#-----------------------------------------------------------------------
from twitter import *
#-----------------------------------------------------------------------
# load our API credentials
#-----------------------------------------------------------------------
import sys
sys.path.append(".")
import 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"])