Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- If it will be helpful, please like this post
- """
- from bs4 import BeautifulSoup as bs
- import requests
- import urllib.request
- import ssl
- ssl._create_default_https_context = ssl._create_unverified_context
- """
- This is basic parser of weather from google
- Using:
- ----Write to input_box(or to bot if we gonna use telegram)
- ----If town(coordinates) is exists: get temperture fot today + describe weather feeling.
- ----If town(coordinates) is not exists: don't get tempreture.
- """
- if __name__ == '__main__':
- headers = {
- 'User-Agent': ''}
- url = f"https://www.google.com/search?q=погода+в+{str(input())}"
- parser = requests.get(url)
- if parser.status_code == 200:
- soup = bs(parser.text, 'html.parser')
- try:
- temp = soup.find('div', class_='BNeawe iBp4i AP7Wnd').text
- date, status = soup.find('div', class_='BNeawe tAd8D AP7Wnd').text.split('\n')
- except:
- print('Нет данных по такому городу')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement