From 7d406c5dc0e96f285c4eede3a7539779a9e787ac Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 15 Aug 2023 01:42:44 +0100 Subject: [PATCH] Misc log change --- twExtract/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twExtract/__init__.py b/twExtract/__init__.py index 005d8b5..c137b7a 100644 --- a/twExtract/__init__.py +++ b/twExtract/__init__.py @@ -118,14 +118,14 @@ def extractStatusV2(url): vars = json.loads('{"includeTweetImpression":true,"includeHasBirdwatchNotes":false,"includeEditPerspective":false,"rest_ids":["x"],"includeEditControl":true,"includeCommunityTweetRelationship":true,"includeTweetVisibilityNudge":true}') vars['rest_ids'][0] = str(twid) tweet = requests.get(f"https://twitter.com/i/api/graphql/{v2graphql_api}/TweetResultsByIdsQuery?variables={urllib.parse.quote(json.dumps(vars))}&features={urllib.parse.quote(v2Features)}", headers={"Authorization":v2Bearer,"Cookie":f"auth_token={authToken}; ct0={csrfToken}; ","x-twitter-active-user":"yes","x-twitter-auth-type":"OAuth2Session","x-twitter-client-language":"en","x-csrf-token":csrfToken,"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0"}) - if tweet.status_code == 429: - # try another token - continue try: rateLimitRemaining = tweet.headers.get("x-rate-limit-remaining") print(f"Twitter Token Rate limit remaining: {rateLimitRemaining}") except: # for some reason the header is not always present pass + if tweet.status_code == 429: + # try another token + continue output = tweet.json() if "errors" in output: