upd send rules

This commit is contained in:
Rykov7
2023-01-23 14:44:29 +03:00
parent 44f6771c49
commit bbb0cbc9b5
4 changed files with 25 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
from bs4 import BeautifulSoup
from urllib.request import urlopen
html = BeautifulSoup(urlopen('https://telegra.ph/pythonchatru-07-07'), 'lxml')
def get_rule(li):
li = int(li)
try:
return html.find_all('li')[li - 1].text
except IndexError:
return 'Нет такого правила.'
if __name__ == '__main__':
print(get_rule(1))