Last active
July 22, 2024 19:49
-
-
Save WindClan/97861c7d6b37b86e2685ac961024739a to your computer and use it in GitHub Desktop.
whatbeatsrock automation api
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
import requests | |
import json | |
import uuid | |
url = "https://www.whatbeatsrock.com/api/vs" | |
previous = "rock" | |
headers = { | |
'Accept': '*/*', | |
'Accept-Encoding': 'gzip, deflate, br, zstd', | |
'Accept-Language': 'en-US,en;q=0.5', | |
'Content-Type': 'application/json', | |
'Origin': 'https://www.whatbeatsrock.com/', | |
'Host': 'www.whatbeatsrock.com', | |
'Referer': 'https://www.whatbeatsrock.com/', | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0' | |
} | |
#gameId = str(uuid.uuid4()) | |
def submitGuess(gameId,guess): | |
global previous | |
dataJson = { | |
'gid': gameId, | |
'guess': guess, | |
'prev': previous | |
} | |
x = requests.post(url, json = dataJson,headers=headers) | |
resp = json.loads(x.text) | |
try: | |
if resp["data"]: | |
dat = resp["data"] | |
if dat["guess_wins"]: | |
previous = guess | |
else: | |
previous = "rock" | |
return dat["guess_wins"], dat["reason"], dat["cached"], dat["cache_count"], dat["guess_emoji"] | |
except: | |
err = resp["error"]:lower() | |
if err = "chill": | |
print("Rate limit exceeded!") | |
else: | |
#if err = "gonna": | |
# print("Something about your activity alerted the website that this isnt website traffic") | |
#else: | |
# print("Error code: "+err) | |
print("Error code: "+err) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment