-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweather_birth.py
60 lines (48 loc) · 1.53 KB
/
weather_birth.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
59
60
import wikipedia
import requests
from bs4 import BeautifulSoup
from fake_useragent import UserAgent
config_weather = ["сегодня", "завтра"]
def action(url):
response = requests.get(url)
date = []
soup = BeautifulSoup(response.text, "lxml")
x = soup.find("tbody").find_all(scope="row", class_="plainlist")
def bith(qwerty):
qwerty = qwerty.find(class_="nowrap")
for i in qwerty:
date.append(i.text)
date.remove(" ")
return date
for i in x:
if i.text == "Дата рождения":
date = bith(i.parent)
return date
def person(name):
wikipedia.set_lang("ru")
name = wikipedia.page(name).url
date = action(name)
return date
def weather(voice):
url = 'https://www.gismeteo.ru/weather-kolpino-14709/'
response = requests.get(url, headers={"User-Agent": UserAgent().chrome})
soup = BeautifulSoup(response.text, 'lxml')
def detection_day(voice):
for i in config_weather:
if i in voice:
return i
day = detection_day(voice)
if day == "сегодня":
x = soup.find("body").find("div", class_="weathertabs day-1").find("a").find("span", class_="unit unit_temperature_c").text.split()
print(x[0])
elif day == "завтра":
x = soup.find("body").find("div", class_="weathertabs day-1").find_all("a")
for i in x:
if i.get("href") == None:
pass
else:
if "tomorrow" in i.get("href"):
i = i.find("span", class_="unit unit_temperature_c").text.split()
print(i[0])
if __name__ == '__main__':
main()