如何修复twitter api限制

时间:2016-05-07 15:13:20

标签: python limit tweepy

我正在尝试此代码,但它显示我错误 这不是我写的代码来自Avoid twitter api limitation with Tweepy

因为我是新来的,我无法对该帖子发表评论,请帮我解决这个问题

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(key, secret)

api = tweepy.API(auth, wait_on_rate_limit=True)
search = "#hashTag"

for tweet in tweepy.Cursor(api.search,
                           q=search,
                           include_entities=True).items():
    while True: 
        try:
            #tweet = cursor.next()
            cursor.execute('''INSERT INTO MyTable(name, geo, image, source, timestamp, text, rt) VALUES(?,?,?,?,?,?,?)''',(tweet.user.screen_name, str(tweet.geo), tweet.user.profile_image_url, tweet.source, tweet.created_at, tweet.text, tweet.retweet_count))
        except tweepy.TweepError:           
            time.sleep(60 * 15)
            continue
        except StopIteration:
            break
        break
db.commit() 
db.close()

我得到了这个错误

tweepy.error.TweepError: Failed to send request: HTTPSConnectionPool(host='api.twitter.com', port=443): Read timed out. (read timeout=60)

0 个答案:

没有答案