SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import bs4
  2. import requests
  3. class parser():
  4.     def __init__(self, gorod, pogoda):
  5.         self.gorod = gorod
  6.         self.pogoda = pogoda
  7.     def __str__(self):
  8.         return self.gorod
  9.         return self.pogoda
  10.     def get_weather()->str:
  11.         s = requests.get('https://sinoptik.com.ru/погода-' + str(self.gorod))
  12.         b = bs4.BeautifulSoup(s.text, "html.parser")
  13.         day = b.select('.weather__content_tab-day')
  14.         day1 = day[0].getText()
  15.         number = b.select('.weather__content_tab-date')
  16.         nubmer1= number[0].getText()
  17.         month = b.select('.weather__content_tab-month')
  18.         month1 = month[0].getText()
  19.         now = b.select('.weather__article_main_temp')
  20.         now1 = now[0].getText()
  21.         morning = b.select('.weather__article_main_right-table .table__temp')
  22.         morning1 = morning[0].getText()
  23.         prognoz = b.select('.weather__article_description-text')
  24.         prognoz1 = prognoz[0].getText()
  25.         pogoda = "Сегодня: " + nubmer1 + " " + month1 + " " + "," + " " + day1 + "\n" + "Сейчас: " + now1 + "Утром: " + morning1 + "℃" + "\n" +prognoz1
  26.         return pogoda
  27. x=get_weather('ижевск')
  28. izhevsk = parser('ижевск', x)
  29. print(izhevsk.pogoda)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top