[twitter] add 'ratelimit' option (#4251)

This commit is contained in:
Mike Fährmann
2023-07-04 18:17:32 +02:00
parent f86fdf64a6
commit 1bf9f52c99
2 changed files with 16 additions and 0 deletions

View File

@@ -1439,6 +1439,9 @@ class TwitterAPI():
if response.status_code == 429:
# rate limit exceeded
if self.extractor.config("ratelimit") == "abort":
raise exception.StopExtraction("Rate limit exceeded")
until = response.headers.get("x-rate-limit-reset")
seconds = None if until else 60
self.extractor.wait(until=until, seconds=seconds)