如何避免在 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'}
任何建议或提示表示赞赏。提前致谢 :)