2012-12-26 101 views
0

Possible Duplicate:
Trouble with Twitter API using PythonTwitter的API - 404錯誤

當我運行下面的Python代碼:

import twitter 
twitter_search = twitter.Twitter(domain="search.twitter.com") 
trends = twitter_search.trends() 

我得到以下錯誤:

Twitter sent status 404 for URL: trends.json using parameters:() 
details: ?VJ-*?/*V???V?M-.NLOU?R 
?/*??Q(?H,Q(
)??+??(?Vd?(?(%?????????YpD 

誰能給我解釋一下爲什麼?

回答

0

我明白了。正確的代碼應該是:

import twitter 
twitter_api = twitter.Twitter(domain="api.twitter.com", api_version='1') 
WORLD_WOE_ID = 1 # The Yahoo! Where On Earth ID for the entire world 
world_trends = twitter_api.trends._(WORLD_WOE_ID) # get back a callable 
[ trend for trend in world_trends()[0]['trends'] ] # call the callable and iterate through the trends returned