【发布时间】:2017-06-04 23:51:49
【问题描述】:
我尝试无限循环检查所有推文,但如果我使用此代码
import tweepy
import time
no = 1
a = no
consumer_key = 'X'
consumer_secret = 'X'
access_token = 'X-X'
access_token_secret = 'X'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=False)
timeline = api.user_timeline(count = 3)
for t in timeline:
api.destroy_status(t.id)
time.sleep(9)
while no == a:
public_tweets = api.home_timeline()
for tweet in public_tweets:
tweet.text
print tweet.text
if tweet.text == "1":
print "One"
for t in timeline:
api.destroy_status(t.id)
break
if tweet.text == "0":
print "Zero"
for t in timeline:
api.destroy_status(t.id)
break
错误:
Traceback (most recent call last):
File "test.py", line 21, in <module>
public_tweets = api.home_timeline()
File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 245, in _call
return method.execute()
File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 227, in execute
raise RateLimitError(error_msg, resp)
tweepy.error.RateLimitError: [{u'message': u'Rate limit exceeded', u'code': 88}]
我想一直无限循环(比如 15-20 分钟)检查数据 如何编辑 tweepy 文件或删除速率限制文件
【问题讨论】:
标签: python python-2.7 twitter tweepy tweets