2011-04-02 51 views
1

我使用的是由問題與Twitter包由sixohsix

easy_install twitter 

軟件包安裝了一個Twitter的Python包,可以發現在:https://github.com/sixohsix/twitter

我遇到了一些奇怪的錯誤。

import twitter 

twitter_search = twitter.Twitter(domain="search.twitter.com") 
results = twitter_search.search(q="japan") 

比我收到以下錯誤:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.6/dist-packages/twitter-1.6-py2.6.egg/twitter/api.py", line 150, in __call__ 
    return self._handle_response(req, uri, arg_data) 
    File "/usr/local/lib/python2.6/dist-packages/twitter-1.6-py2.6.egg/twitter/api.py", line 165, in _handle_response 
    raise TwitterHTTPError(e, uri, self.format, arg_data) 
twitter.api.TwitterHTTPError: Twitter sent status 404 for URL: 1/search.json using parameters: (q=japan) 
details: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 

<html> 
    <head> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
     <title>The page you were looking for doesn't exist (404)</title> 
     <style type="text/css"> 
      body { background-color: #fff; font-family: Helvetica, sans-serif; } 
      h1 { margin: 10px 0; } 
      img { border: 0; } 
     </style> 
    </head> 
    <body> 
     <a href="/"><img src="/images/search/twitter-logo-large.png"></a> 
     <h1>The page you were looking for doesn't exist.</h1> 
     <p>You may have mistyped the address or the page may have moved.</p> 
    </body> 
</html> 

我可以知道我究竟做錯了什麼?

我使用Ubuntu 10.04,Python 2.6中,並使用Twitter的1.6

+0

哪些Twitter的Python綁定? – 2011-04-02 07:34:51

+0

可能是一個bug,也許在這裏報告https://github.com/sixohsix/twitter/issues – 2011-04-04 17:53:37

回答

1

這是一個圖書館缺陷筆者只是fixed這一點。

問題在於該庫正在版本化資源的路徑,從而導致404錯誤。

您所提供的細節問題的錯誤消息的這部分:

Twitter sent status 404 for URL: 1/search.json using parameters: (q=japan) 

這就告訴我們,該庫試圖訪問的網址是:

http://search.twitter.com/1/search.json?q=japan

相反,它應該已經組裝了這個網址:

http://search.twitter.com/search.json?q=japan

所以,如果你得到最新版本的庫,我認爲這將解決你的問題。