HTTP错误代码:429访问twitter premium API时

时间:2018-06-14 01:26:21

标签: python twitter http-status-code-429

如何避免对twitter premium 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'}

任何建议或提示都表示赞赏。在此先感谢:)

1 个答案:

答案 0 :(得分:1)

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