Python 获取Twitter话题 (API)
2014-06-17 07:32
393 查看
CODE:
RESULT:
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-06-28 @author: guaguastd @name: top_trend_topics.py ''' if __name__ == '__main__': # import json import json # import login, see http://blog.csdn.net/guaguastd/article/details/31706155 from login import twitter_login # get the twitter access api twitter_api = twitter_login() # import trend from trend import trend_place # returns the top 10 trending topics for a specific WOEID while 1: woeid = int(raw_input("\nInput wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): ")) if woeid == 0: break print json.dumps(trend_place(twitter_api, woeid), indent=1)
RESULT:
Input wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): 1 [ { "created_at": "2014-07-05T21:57:13Z", "trends": [ { "url": "http://twitter.com/search?q=%23NEDvsCRC", "query": "%23NEDvsCRC", "name": "#NEDvsCRC", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23GrantLandisDMMe", "query": "%23GrantLandisDMMe", "name": "#GrantLandisDMMe", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23HOLvsCRC", "query": "%23HOLvsCRC", "name": "#HOLvsCRC", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23NetherlandsvsCostaRica", "query": "%23NetherlandsvsCostaRica", "name": "#NetherlandsvsCostaRica", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23alargamiento", "query": "%23alargamiento", "name": "#alargamiento", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22Robin+Van+Torres%22", "query": "%22Robin+Van+Torres%22", "name": "Robin Van Torres", "promoted_content": null }, { "url": "http://twitter.com/search?q=Kirgizi%C3%AB", "query": "Kirgizi%C3%AB", "name": "Kirgizi\u00eb", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22Crazy+Game%22", "query": "%22Crazy+Game%22", "name": "Crazy Game", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22MusulKerk%C3%BCkT%C3%BCrkistan+T%C3%BCrkElleriPeri%C5%9Fan%22", "query": "%22MusulKerk%C3%BCkT%C3%BCrkistan+T%C3%BCrkElleriPeri%C5%9Fan%22", "name": "MusulKerk\u00fckT\u00fcrkistan T\u00fcrkElleriPeri\u015fan", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22Fan+Persie%22", "query": "%22Fan+Persie%22", "name": "Fan Persie", "promoted_content": null } ], "as_of": "2014-07-05T22:04:56Z", "locations": [ { "woeid": 1, "name": "Worldwide" } ] } ] Input wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): 23424977 [ { "created_at": "2014-07-05T22:01:08Z", "trends": [ { "url": "http://twitter.com/search?q=%23NEDvsCRC", "query": "%23NEDvsCRC", "name": "#NEDvsCRC", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23GrantLandisDMMe", "query": "%23GrantLandisDMMe", "name": "#GrantLandisDMMe", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23CRCvsNED", "query": "%23CRCvsNED", "name": "#CRCvsNED", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23askskai", "query": "%23askskai", "name": "#askskai", "promoted_content": null }, { "url": "http://twitter.com/search?q=%23NetherlandsvsCostaRica", "query": "%23NetherlandsvsCostaRica", "name": "#NetherlandsvsCostaRica", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22Happy+5th+of+July%22", "query": "%22Happy+5th+of+July%22", "name": "Happy 5th of July", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22Barney+Hall%22", "query": "%22Barney+Hall%22", "name": "Barney Hall", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22Josh+Gordon%22", "query": "%22Josh+Gordon%22", "name": "Josh Gordon", "promoted_content": null }, { "url": "http://twitter.com/search?q=%22Van+Persie%22", "query": "%22Van+Persie%22", "name": "Van Persie", "promoted_content": null }, { "url": "http://twitter.com/search?q=Cervelli", "query": "Cervelli", "name": "Cervelli", "promoted_content": null } ], "as_of": "2014-07-05T22:05:15Z", "locations": [ { "woeid": 23424977, "name": "United States" } ] } ] Input wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): 0
相关文章推荐
- Python 获取新浪微博的热门话题 (API)
- Python 获取新浪微博的热门话题 (API)
- Python 对Twitter中指定话题的被转载Tweet数量的频谱分析
- Python 查找Twitter中特定话题中最流行(转载最多)的10个Tweet
- paip.获取文件名从路径uapi java python php总结...
- Python:新浪微博API的使用及安全的模拟登陆自动获取code值
- python adodbapi 获取insert的自增ID
- 【Amazon EC2 Python API系列】获取实例信息
- selenium2+python元素状态获取api
- 利用google的API获取世界城市经纬度(python实现)
- sigar模块之python api简单的使用--获取cpu信息
- 01-Twitter Streaming API的调用 | 02.数据获取
- Python实现从百度API获取天气的方法
- Python实现从百度API获取天气的方法
- Python 获取Twitter用户的所有的friends和followers
- 提供一个Twitter的API(Python)
- paip.uapi 获取网络url内容html 的方法java php ahk c++ python总结.
- Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)
- Python 对Twitter中指定话题的Tweet基本元素的频谱分析