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
|