refresh token in iterate script

This commit is contained in:
TheTechRobo 2022-04-03 19:43:45 -04:00
parent 4a98f86847
commit ea8fbee4c1
1 changed files with 16 additions and 1 deletions

View File

@ -1,9 +1,24 @@
import requests, time
from rethinkdb import r
def refresh_token():
place = requests.get("https://reddit.com/r/place").text
i = place.index('''"session":{"accessToken":"''')
tok = place[i + 26 : i + 57]
return tok
tok = refresh_token()
for x in range(0, 1000):
for y in range(0, 1000):
data = {"operationName":"pixelHistory","variables":{"input":{"actionName":"r/replace:get_tile_history","PixelMessageData":{"coordinate":{"x":x,"y":y},"colorIndex":0,"canvasIndex":3}}},"query":"mutation pixelHistory($input: ActInput!) {\n act(input: $input) {\n data {\n ... on BasicMessage {\n id\n data {\n ... on GetTileHistoryResponseMessageData {\n lastModifiedTimestamp\n userInfo {\n userID\n username\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"}
a = requests.post("https://gql-realtime-2.reddit.com/query", json=data, headers={"Authorization": "Bearer 453755016066-TyqOc6Xn80g2ONC_fb1m9wAB-oalJA"})
ep = "https://gql-realtime-2.reddit.com/query"
head = {"Authorization": f"Bearer {tok}"}
a = requests.post(ep, json=data, headers=head)
while a.status_code != 200:
print(a.text)
a = requests.post(ep, json=data, headers=head)
tok = refresh_token()
print("Added", x, y)
time.sleep(0.09)