Created
June 21, 2021 03:31
-
-
Save jmkd3v/cc53b48ccc2bf8a35a39cc4fdc9b28f3 to your computer and use it in GitHub Desktop.
ro.py cursor debugger
This file contains 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
from ro_py import Client | |
from dateutil.parser import isoparse | |
import asyncio | |
import base64 | |
import time | |
import json | |
client = Client() | |
requests = client.requests | |
line = "="*40 | |
async def main(): | |
cursor = None | |
print("Starting...") | |
print(line) | |
while True: | |
print("Sending request...") | |
req_t0 = time.perf_counter() | |
req = await requests.get( | |
url="https://badges.roblox.com/v1/users/2/badges", | |
params={ # ?limit=10&sortOrder=Asc | |
"limit": 10, | |
"sortOrder": "Asc", | |
"cursor": cursor | |
} | |
) | |
req_t1 = time.perf_counter() | |
print(f"Done in {req_t1 - req_t0:0.4f} seconds.") | |
data = req.json() | |
cursor = data["nextPageCursor"] | |
if not cursor: | |
print("Cursor not not found. Ending.") | |
break | |
print(f"Cursor: {cursor}") | |
decoded_cursor = str(base64.b64decode(cursor), "utf-8") | |
decoded_cursor_split = decoded_cursor.split("\n") | |
decoded_cursor_data = json.loads(decoded_cursor_split[0]) | |
# print(f"Data: {decoded_cursor_data}") | |
print(f"Cursor JSON Data: {decoded_cursor_split[0]}") | |
print(f"Nonce: {decoded_cursor_split[1]}") | |
print("\nThe following is parsed data from the cursor's JSON data:") | |
print("Key ID:", decoded_cursor_data["key"]["id"]) | |
iso_award_date = decoded_cursor_data["key"]["awardDateTime"] | |
parsed_award_date = isoparse(iso_award_date) | |
clean_award_date = parsed_award_date.strftime("%Y-%m-%d %H:%M") | |
print("Key Award Date:", clean_award_date, f"({iso_award_date})") | |
print("Sort Order:", decoded_cursor_data["sortOrder"]) | |
print("Paging Direction:", decoded_cursor_data["pagingDirection"]) | |
print("Page Number:", decoded_cursor_data["pageNumber"]) | |
print("Discriminator:", decoded_cursor_data["discriminator"]) | |
print("Count:", decoded_cursor_data["count"]) | |
print(line) | |
print(line) | |
print("Completed. Sent x requests in x seconds.") | |
asyncio.get_event_loop().run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK