Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- months = ['january', 'february', 'march', 'april','may', 'june', 'july', 'august', 'september', 'october', 'november',
- 'december']
- def get_html(url):
- respon = requests.get(url)
- return respon.text
- def parse_weather_month(html):
- soup = BeautifulSoup(html, 'lxml')
- table = soup.find('div', class_='climate-calendar').find_all('div','climate-calendar__row')
- weather_g = {}
- for j in table:
- if ('climate-calendar__row_header') not in j['class']:
- for z in j:
- if 'climate-calendar-day_colorless_yes' not in z.find('div')['class']:
- weather = z.find('div', 'temp climate-calendar-day__temp-day').text.strip()
- day = z.find('div', class_='climate-calendar-day__day').text
- print(day)
- for q in range(12):
- url = 'https://yandex.ru/pogoda/novosibirsk/month/' + months[q]
- html = get_html(url)
- parse_weather_month(html)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement