I am using a Twitter Python package which is installed by
easy_install twitter
The package can be found at : https://github.com/sixohsix/twitter
I am running into some weird errors.
import twitter
twitter_search = twitter.Twitter(domain="search.twitter.com")
results = twitter_search.search(q="japan")
Than I received the following error:
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>
May I know what am I doing wrong开发者_开发百科?
I am using Ubuntu 10.04, Python 2.6, and using twitter-1.6
This was a library defect that the author just fixed.
The problem was that the library was versioning the path to the search resource, and thereby causing a 404 error.
This part of the error message you provided details the problem:
Twitter sent status 404 for URL: 1/search.json using parameters: (q=japan)
This tells us that the URL the library was trying to access was:
http://search.twitter.com/1/search.json?q=japan
Instead, it should have assembled this URL:
http://search.twitter.com/search.json?q=japan
So, if you get the latest version of the library, I think that will solve your issue.
精彩评论