0

如何避免在 twitter 高级 API 上受到速率限制?我可以得到一个新的端点,但是,我该如何避免犯这个错误。我需要从很多天中提取很多推文。我什至在 5 小时后尝试了相同的端点,但仍然出现相同的错误。

   from searchtweets import collect_results,ResultStream, gen_rule_payload, load_credentials
   import csv
   premium_search_args = load_credentials("E:\\residency_5\\practicum\\twitter_keys.yaml",yaml_key="search_tweets_premium",env_overwrite=False)

   rule = gen_rule_payload("#whistlepodu", to_date="2018-04-07",from_date="2018-04-08", results_per_call=100)
   print(rule)

   tweets = collect_results(rule,
                     max_results=5,
                     result_stream_args=premium_search_args)
   csvFile = open('E:\\residency_5\\practicum\\whistlepodu\\2.csv', 'a')

   csvWriter = csv.writer(csvFile)

   for tweet in tweets:
       csvWriter.writerow([str(tweet.created_at_datetime), tweet.all_text.encode('utf-8'),tweet.hashtags,tweet.favorite_count,tweet.retweet_count])

   csvFile.close()

我收到以下错误:

 retrying request; current status code: 429
 retrying request; current status code: 429
 retrying request; current status code: 429
 HTTP Error code: 429: Request exceeds account’s current query limits. Please upgrade to the next package level and retry.
 Rule payload: {'query': '#whistlepodu', 'maxResults': 100, 'toDate': '201804070000', 'fromDate': '201804080000'}

任何建议或提示表示赞赏。提前致谢 :)

4

1 回答 1

1

https://developer.twitter.com/en/docs/ads/general/guides/response-codes.html如您在此处看到的,这些错误代码表示您已达到 TOO_MANY_REQUESTS 或 TWEET_RATE_LIMIT_EXCEEDED。

于 2018-06-14T01:49:38.877 回答