improve rules

This commit is contained in:
Rykov7
2023-01-23 17:58:12 +03:00
parent 0a8263e2e4
commit 32b63b3510
+5 -4
View File
@@ -6,7 +6,8 @@ html = BeautifulSoup(urlopen('https://telegra.ph/pythonchatru-07-07'), 'lxml')
def get_rule(li): def get_rule(li):
li = int(li) li = int(li)
try: lis = html.find_all('li')
return html.find_all('li')[li - 1].text if li <= len(lis):
except IndexError: return lis[li - 1].text
return 'Нет такого правила.' else:
return f'Пока не придумали.'