Spaces:
Runtime error
Runtime error
File size: 1,100 Bytes
ab01137 e2782ab dda94e6 e05b307 e2782ab 8a87758 e2782ab ab01137 dda94e6 e05b307 e2782ab e05b307 8a87758 e2782ab e05b307 e2782ab ab01137 b33d6d1 ab01137 8a87758 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from datetime import date, datetime
from pytz import utc, timezone
import requests
def get_secret():
puzzle_num = get_puzzle_num()
request_url = f"https://semantoru.com/yesterday/{puzzle_num+1}"
response = requests.get(request_url, timeout=5)
if response.status_code == 200:
return response.content
else:
return "Not found error."
def get_guess(word: str):
puzzle_num = get_puzzle_num()
request_url = f"https://semantoru.com/guess/{puzzle_num}/{word}"
print(request_url)
response = requests.get(request_url, timeout=5)
print(response.status_code)
if response.status_code == 200:
rtn = response.json()
print(rtn)
if rtn['rank'] == '正解!':
return rtn
elif rtn['rank'] > 1000:
rtn['rank'] = '?'
return rtn
else:
return {"guess": word,
"sim": None,
"rank": None}
def get_puzzle_num():
fisrt_day = date(2023, 4, 2)
return (utc.localize(datetime.utcnow()).astimezone(timezone('Asia/Tokyo')).date() - fisrt_day).days |