-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom-wordsearch.py
31 lines (25 loc) · 1.02 KB
/
random-wordsearch.py
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
import requests, json, webbrowser, glob, random
cookies = {}
headers = {
'accept': '*/*',
'cache-control': 'no-cache',
'content-type': 'application/x-www-form-urlencoded',
'origin': 'https://thewordsearch.com',
'pragma': 'no-cache',
'referer': 'https://thewordsearch.com/maker/',
}
words = list(map(lambda s: s.replace('englishpic\\', '')[:-4], random.sample((l := [w for w in glob.glob('englishpic/*.jpg') if len(w) <= 30]), k=min(len(l), 30)))) # get random words ['an', 'apple', 'is', 'on', 'the', 'tree']
_json = {'id': -1, 'hash': '', 'ispersonal': 0, 'title': 'Your game title', 'desc': 'Your list description', 'wordlist': words}
print(_json["wordlist"])
data = {
'json': json.dumps(_json, separators=(',',':')),
}
response = requests.post(
'https://thewordsearch.com/api/pri/testapikey/save_word_search/',
cookies=cookies,
headers=headers,
data=data,
)
id = json.loads(response.text)["result"]["id"]
url = f'https://thewordsearch.com/puzzle/{id}'
webbrowser.open(url, new=0, autoraise=True)