Python 获取Twitter话题 (API)
来源:互联网 发布:seo站点 编辑:程序博客网 时间:2024/05/19 13:55
CODE:
#!/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
0 0
- Python 获取Twitter话题 (API)
- twitter API获取和使用(python tweepy库)
- Python 提取Twitter特定话题中转载tweet的用户
- Python 获取Twitter搜索结果
- 提供一个Twitter的API(Python)
- Python 获取两个话题的交集
- twitter api
- twitter api
- Python 查找Twitter中特定话题中最流行的10个转发Tweet
- Python 可视化Twitter中指定话题中Tweet的词汇频率
- Python 对Twitter中指定话题的Tweet基本元素的频谱分析
- Python 对Twitter中指定话题的被转载Tweet数量的频谱分析
- Python 查找Twitter中特定话题中最流行(转载最多)的10个Tweet
- Python 获取Twitter用户的所有的friends和followers
- Twitter API中文文档
- Twitter API中文文档
- Twitter API Rate Limit
- Twitter API中文文档
- 代码里的命名规则:错误的和正确的对比
- LINUX popen实现system系统调用
- ACL的定义及作用
- ACL的设定及查询
- 内存像素值采用CreateBitmap显示不正常的解决方法
- Python 获取Twitter话题 (API)
- 《her》与人工智能
- Android 中 设置TextView垂直滚动
- C语言中的面向对象思想
- 张瑞敏不断强调要用 “互联网思维”改造制造业,以达到“智能无人化”的制造环境。
- Win7 + Suse Linux Enterprise 11 SP3 + OS X 10.9组合搭建开发环境
- JS学习笔记2
- 【足迹C++primer】31、初识泛型算法
- calling lua from c in linux