sixohsix的Twitter包问题
我正在使用一个Twitter的Python库,这个库是通过
easy_install twitter
安装的。你可以在这里找到这个库: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。
1 个回答
1
这是一个库里的缺陷,作者刚刚修复了它。
问题在于,这个库在处理搜索资源的路径时出了错,导致出现了404错误,也就是找不到页面。
你提供的错误信息中有一部分说明了问题所在:
Twitter sent status 404 for URL: 1/search.json using parameters: (q=japan)
这告诉我们,库试图访问的URL是:
http://search.twitter.com/1/search.json?q=japan
但实际上,它应该拼接成这个URL:
http://search.twitter.com/search.json?q=japan
所以,如果你更新到这个库的最新版本,我觉得这会解决你的问题。