python - sixohsix 的 Twitter 包问题

标签 python ubuntu 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

最佳答案

这是一个库缺陷,作者只是 fixed .

问题是库正在对 search 的路径进行版本控制 资源,从而导致 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

因此,如果您获得最新版本的库,我认为这将解决您的问题。

关于python - sixohsix 的 Twitter 包问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5521848/

相关文章:

c - 获取 nan 作为累加和

android - 由于缺少依赖项,Twitter Fabric 无法在 Android Studio 中安装

Python interpteter 无法在 virtualenv 中找到模块,但 pip 看到它并且不会安装

python - 角点检测中的非极大值抑制

python - Django filter_horizo​​ntal 形式

android-studio - 使用 WSL Ubuntu 在 Windows 机器上配置 CAPACITOR_ANDROID_STUDIO_PATH 环境变量

c - (Osh) Omake 错误 : Unexpected Token: String: {

python - 在 Python 中使用空格字符作为分隔符将句子分成单词

css - 如何在CSS中的每条推文之前添加一个空格

Python - Tweepy,检索created_at