Changes to used token logic
This commit is contained in:
parent
ee09073e2b
commit
25ebf7d9d3
@ -43,7 +43,6 @@ def extractStatus_token(url):
|
|||||||
usedTokens.clear()
|
usedTokens.clear()
|
||||||
random.shuffle(tokens)
|
random.shuffle(tokens)
|
||||||
for authToken in tokens:
|
for authToken in tokens:
|
||||||
usedTokens.append(authToken)
|
|
||||||
try:
|
try:
|
||||||
csrfToken=str(uuid.uuid4()).replace('-', '')
|
csrfToken=str(uuid.uuid4()).replace('-', '')
|
||||||
tweet = requests.get("https://api.twitter.com/1.1/statuses/show/" + twid + ".json?tweet_mode=extended&cards_platform=Web-12&include_cards=1&include_reply_count=1&include_user_entities=0", headers={"Authorization":bearer,"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"})
|
tweet = requests.get("https://api.twitter.com/1.1/statuses/show/" + twid + ".json?tweet_mode=extended&cards_platform=Web-12&include_cards=1&include_reply_count=1&include_user_entities=0", headers={"Authorization":bearer,"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"})
|
||||||
@ -126,7 +125,6 @@ def extractStatusV2(url):
|
|||||||
usedTokens.clear()
|
usedTokens.clear()
|
||||||
random.shuffle(tokens)
|
random.shuffle(tokens)
|
||||||
for authToken in tokens:
|
for authToken in tokens:
|
||||||
usedTokens.append(authToken)
|
|
||||||
try:
|
try:
|
||||||
csrfToken=str(uuid.uuid4()).replace('-', '')
|
csrfToken=str(uuid.uuid4()).replace('-', '')
|
||||||
vars = json.loads('{"includeTweetImpression":true,"includeHasBirdwatchNotes":false,"includeEditPerspective":false,"rest_ids":["x"],"includeEditControl":true,"includeCommunityTweetRelationship":true,"includeTweetVisibilityNudge":true}')
|
vars = json.loads('{"includeTweetImpression":true,"includeHasBirdwatchNotes":false,"includeEditPerspective":false,"rest_ids":["x"],"includeEditControl":true,"includeCommunityTweetRelationship":true,"includeTweetVisibilityNudge":true}')
|
||||||
@ -135,10 +133,14 @@ def extractStatusV2(url):
|
|||||||
try:
|
try:
|
||||||
rateLimitRemaining = tweet.headers.get("x-rate-limit-remaining")
|
rateLimitRemaining = tweet.headers.get("x-rate-limit-remaining")
|
||||||
print(f"Twitter Token Rate limit remaining: {rateLimitRemaining}")
|
print(f"Twitter Token Rate limit remaining: {rateLimitRemaining}")
|
||||||
|
if (rateLimitRemaining == "0"):
|
||||||
|
usedTokens.append(authToken)
|
||||||
|
continue
|
||||||
except: # for some reason the header is not always present
|
except: # for some reason the header is not always present
|
||||||
pass
|
pass
|
||||||
if tweet.status_code == 429:
|
if tweet.status_code == 429:
|
||||||
# try another token
|
# try another token
|
||||||
|
usedTokens.append(authToken)
|
||||||
continue
|
continue
|
||||||
output = tweet.json()
|
output = tweet.json()
|
||||||
|
|
||||||
@ -208,7 +210,6 @@ def extractUser(url):
|
|||||||
usedTokens.clear()
|
usedTokens.clear()
|
||||||
random.shuffle(tokens)
|
random.shuffle(tokens)
|
||||||
for authToken in tokens:
|
for authToken in tokens:
|
||||||
usedTokens.append(authToken)
|
|
||||||
try:
|
try:
|
||||||
csrfToken=str(uuid.uuid4()).replace('-', '')
|
csrfToken=str(uuid.uuid4()).replace('-', '')
|
||||||
reqHeaders = {"Authorization":bearer,"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"}
|
reqHeaders = {"Authorization":bearer,"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"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user