2011-04-02 50 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

所以,如果你得到最新版本的库,我认为这将解决你的问题。