-
Notifications
You must be signed in to change notification settings - Fork 1
/
weather.py
58 lines (42 loc) · 2.18 KB
/
weather.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import re
import requests
from bs4 import BeautifulSoup
class Weather:
@staticmethod
def get_weather_today() -> list:
http = "https://sinoptik.com.ru/погода-санкт-петербург"
b = BeautifulSoup(requests.get(http).text, "html.parser")
# result = ''
# result = result + ('Утром :' + weather1) + '\n'
# result = result + ('Днём :' + weather3 + ' ' + weather4) + '\n'
temp = b.select('.weather__article_description-text')
weather = temp[0].getText()
url = 'https://yandex.ru/pogoda/2'
soup = BeautifulSoup(requests.get(url).text, "html.parser")
current_weather = soup.find('div', {'class': 'fact__time-yesterday-wrap'})
current_weather_temperature = soup.find('div', {'class': 'temp fact__temp fact__temp_size_s'})
current_weather_temperature1 = soup.find('div', {'class': 'term term_orient_h fact__feels-like'})
result = current_weather.text + '\n' + current_weather_temperature.text + '\n' + current_weather_temperature1.text + '\n' + weather.strip()
return result
#print(Weather.get_weather_today())
class Citata:
@staticmethod
def get_citata() -> list:
http = "https://citaty.info/random/"
b = BeautifulSoup(requests.get(http).text, "html.parser")
temp = b.find('div', {'class': 'field-item even last'})
return temp.text
def rohan(request):
if re.search(r'\bГондор зовет на помощь\b', request):
citations = ['И Рохан явится',
'И Рохан явится',
'И Рохан явится']
elif re.search(r'\bжопа\b', request):
citations = ['Рохан не говорит "жопа" пёс!', 'Пertertшитель', 'Эрэктус тебе в мармелад', 'Зубы на стол',
'Оглянись!']
elif re.search(r'\b1111\b', request):
citations = ['Рох22ит "жопа" пёс!', 'Пer222ель', 'Эрэкту222мармелад', 'Зу222 стол',
'Огw33сь!']
else:
citations = ["Рохан недоволен тобою."]
return citations