• 🌙 Community Spirit

    Ramadan Mubarak! To honor this month, Crax has paused NSFW categories. Wishing you peace and growth!

Get Live Weather Desktop Notifications Using Python (1 Viewer)

Currently reading:
 Get Live Weather Desktop Notifications Using Python (1 Viewer)

Recently searched:

m3uZael

Member
LV
0
Joined
Jan 25, 2024
Threads
11
Likes
0
Awards
2
Credits
965©
Cash
0$
Python:
# import required libraries
import requests
from bs4 import BeautifulSoup
from win10toast import ToastNotifier

# create an object to ToastNotifier class
n = ToastNotifier()

# define a function
def getdata(url):
    r = requests.get(url)
    return r.text
    
htmldata = getdata("https://weather.com/en-IN/weather/today/l/25.59,85.14?par=google&temp=c/")

soup = BeautifulSoup(htmldata, 'html.parser')

current_temp = soup.find_all("span", class_= "_-_-components-src-organism-CurrentConditions-CurrentConditions--tempValue--MHmYY")

chances_rain = soup.find_all("div", class_= "_-_-components-src-organism-CurrentConditions-CurrentConditions--precipValue--2aJSf")

temp = (str(current_temp))

temp_rain = str(chances_rain)

result = "current_temp " + temp[128:-9] + " in patna bihar" + "\n" + temp_rain[131:-14]
n.show_toast("live Weather update",
            result, duration = 10)
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Recently searched:

Similar threads

Users who are viewing this thread

Top Bottom