Created
October 22, 2023 13:38
-
-
Save tvorogme/6839002510010e275e0339c0847a12ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from time import sleep | |
def f(x): | |
return """{ | |
transactions( | |
address_friendly: "Ef8gQpp7pKD9GzBrcr3ju9faPjEWHPerhZ4tFpSiDoDUINxn", | |
order_by: "lt" | |
lt_gt: """ + '"' + str(x) + '"' + """ | |
page_size: 150 | |
page: 0 | |
) { | |
gen_utime | |
hash | |
lt | |
} | |
}""" | |
endpoint = 'https://dton.io/graphql/' | |
cur = 0 | |
total = [] | |
while True: | |
response = requests.post(endpoint, json={'query': f(cur)}) | |
try: | |
data = response.json()['data']['transactions'] | |
except Exception as e: | |
sleep(1) | |
continue | |
print(f"Got: {len(data)}") | |
cur = int(max([i['lt'] for i in data])) | |
if len(data) == 0: | |
break | |
else: | |
total.extend(data) | |
sleep(1) | |
print(len(total)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment