-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiction.py
32 lines (32 loc) · 948 Bytes
/
diction.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
32
import requests
import urllib3
urllib3.disable_warnings()
try:
def check_word(word:str):
slownik = {
"ą":"%C4%85",
"ć":"%C4%87",
"ę":"%C4%99",
"ł":"%C5%82",
"ń":"%C5%84",
"ó":"%C3%B3",
"ś":"%C5%9B",
"ź":"%C5%BA",
"ż":"%C5%BC"
}
word = word.lower()
for i, j in slownik.items():
word = word.replace(i,j)
url = f'https://sjp.pl/{word}'
check = requests.get(url, verify=False)
status = check.status_code
if (">dopuszczalne" in check.text and "niedopuszczalne w grach <" in check.text):
return True
if "niedopuszczalne w grach <" in check.text:
return False
elif status != 200:
return False
return True
except requests.exceptions.ConnectionError:
print( "Connection refused")
#Karol Majewski