我刚刚开始使用twython,但在第一个示例中:
from twython import Twython
t = Twython()
t.search(q='python')我收到了一个异常:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/twython-2.5.2-py2.7.egg/twython/twython.py", line 367, in search
return self.get('https://api.twitter.com/1.1/search/tweets.json', params=kwargs)
File "/usr/local/lib/python2.7/dist-packages/twython-2.5.2-py2.7.egg/twython/twython.py", line 238, in get
return self.request(endpoint, params=params, version=version)
File "/usr/local/lib/python2.7/dist-packages/twython-2.5.2-py2.7.egg/twython/twython.py", line 233, in request
content = self._request(url, method=method, params=params, files=files, api_call=url)
File "/usr/local/lib/python2.7/dist-packages/twython-2.5.2-py2.7.egg/twython/twython.py", line 210, in _request
retry_after=response.headers.get('retry-after'))
twython.twython.TwythonError: 'Bad Request: The request was invalid. An accompanying error message will explain why. This is the status code will be returned during rate limiting. -- An error occurred processing your request.'有人知道是什么导致了这个异常吗?
谢谢,
我
发布于 2012-11-16 17:27:59
未经身份验证的Twitter API调用。请阅读此处- https://dev.twitter.com/docs/rate-limiting。
发布于 2013-01-12 01:40:48
from twython import Twython
""" Instantiate Twython with no Authentication """
twitter = Twython()
search_results = twitter.search(q="python", rpp="50")
for tweet in search_results["results"]:
print "Tweet from @%s Date: %s" % (tweet['from_user'].encode('utf-8'),tweet['created_at'])
print tweet['text'].encode('utf-8'),"\n"我试过了,它起作用了。
https://stackoverflow.com/questions/13413557
复制相似问题