Skip to content

Commit 07b963d

Browse files
authored
Merge pull request larymak#55 from harshadbhere/master
Initial Commit
2 parents 9929668 + 61e9ae0 commit 07b963d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Weather Updates/Readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Weather Updates
2+
3+
##Install required packages:
4+
pip install requests
5+
pip install bs4
6+
pip install plyer
7+
8+
You will also need the URL with your city searched on weather.com. Change the url in line no.7 to your url and run the script to get weatherupdates.

Weather Updates/WeatherUpdate.JPG

15.5 KB
Loading

Weather Updates/WeatherUpdates.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
from plyer import notification
4+
def get_data(url):
5+
data = requests.get(url)
6+
return data
7+
raw_data = get_data('https://weather.com/en-IN/weather/today/l/e1bbaf5ba44a74170e3bb9f892416301c36b3b17f37e1a666c6e1213de0f5668')
8+
bs = BeautifulSoup(raw_data.text, 'html.parser')
9+
temperature = bs.find_all("span", class_ = "CurrentConditions--tempValue--1RYJJ")
10+
conditions = bs.find_all("div", class_ = "CurrentConditions--phraseValue--17s79")
11+
city_name = bs.find_all("h1", class_ = "CurrentConditions--location--2_osB")
12+
for i,j,k in zip(temperature,conditions,city_name):
13+
temp = str(i.text)
14+
condi = str(j.text)
15+
city = str(k.text)
16+
weather_update = "Current temperature is: " + temp + "\nCurrent conditions: " + condi
17+
city.replace(' ',',')
18+
city = city.split(',')
19+
notification.notify(
20+
title = city[0] + " weather update",
21+
message = weather_update,
22+
timeout = 5,
23+
app_icon = None
24+
)

0 commit comments

Comments
 (0)