-
Notifications
You must be signed in to change notification settings - Fork 11
/
oscon2012_trends.py
33 lines (32 loc) · 1.01 KB
/
oscon2012_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
#!/usr/bin/env python
import requests
import json
from requests.auth import HTTPBasicAuth
#
# Get Trending Topics
#
# http://api.twitter.com/1/trends/:woeid.format
# woeid=1 = global
# https://dev.twitter.com/docs/api/1/get/trends/%3Awoeid
# http://engineering.twitter.com/2010/02/woeids-in-twitters-trends.html
# https://dev.twitter.com/blog/changing-trends-api
# https://dev.twitter.com/docs/api/1/get/trends/available
# Get available trends
# For a day
url = 'http://api.twitter.com/1/trends/daily.json'
payload={"date":"2012-07-07"}
r = requests.get(url, params=payload)
print json.dumps(r.headers,sort_keys=True,indent=2)
print json.dumps(r.json,sort_keys=True,indent=2)
#
'''
url = 'http://api.twitter.com/trends/available.json'
r = requests.get(url)
print json.dumps(r.headers,sort_keys=True,indent=2)
print json.dumps(r.json,sort_keys=True,indent=2)
#
url='http://api.twitter.com/1/trends/1.json'
r = requests.get(url)
print json.dumps(r.headers,sort_keys=True,indent=2)
print json.dumps(r.json,sort_keys=True,indent=2)
'''