File size: 877 Bytes
ab01137
 
e2782ab
dda94e6
e2782ab
 
8a87758
e2782ab
 
 
ab01137
dda94e6
e2782ab
 
8a87758
e2782ab
 
ab01137
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
from datetime import date, datetime
from pytz import utc, timezone
import requests

def get_secret(puzzle_num: int):
    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: int):
    request_url = f"https://semantoru.com/guess/{puzzle_num}/{word}"
    response = requests.get(request_url, timeout=5)
    print(response.status_code)
    if response.status_code == 200:
        return response.json()
    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