Last active
August 23, 2024 13:42
-
-
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) |
The errors on the site are very cryptic on purpose. They only happen if you are detected as a bot. They spell out "Never gonna give you up"
Maybe you repeated a guess
Do you know about submitting scores? I tried to implement similar code but i get {"error": "yawn"}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello ! Thank you for this code, it really helps me with my side project. Just a question, I'm having an error "never" that seems to happen after 3 rounds of a game, do you know what it means ? Thank you !