()
| 6 | root.title("Weather") |
| 7 | root.config(bg="white") |
| 8 | def getWeather(): |
| 9 | page = requests.get(url) |
| 10 | soup = BeautifulSoup(page.content, "html.parser") |
| 11 | location = soup.find("h1", class_="_1Ayv3").text |
| 12 | temperature = soup.find("span", class_="_3KcTQ").text |
| 13 | airquality = soup.find("text", class_="k2Z7I").text |
| 14 | airqualitytitle = soup.find("span", class_="_1VMr2").text |
| 15 | sunrise = soup.find("div", class_="_2ATeV").text |
| 16 | sunset = soup.find("div", class_="_2_gJb _2ATeV").text |
| 17 | # humidity = soup.find('div',class_='_23DP5').text |
| 18 | wind = soup.find("span", class_="_1Va1P undefined").text |
| 19 | pressure = soup.find("span", class_="_3olKd undefined").text |
| 20 | locationlabel.config(text=(location)) |
| 21 | templabel.config(text=temperature + "C") |
| 22 | WeatherText = ( |
| 23 | "Sunrise : " |
| 24 | + sunrise |
| 25 | + "\n" |
| 26 | + "SunSet : " |
| 27 | + sunset |
| 28 | + "\n" |
| 29 | + "Pressure : " |
| 30 | + pressure |
| 31 | + "\n" |
| 32 | + "Wind : " |
| 33 | + wind |
| 34 | + "\n" |
| 35 | ) |
| 36 | weatherPrediction.config(text=WeatherText) |
| 37 | airqualityText = airquality + " " * 5 + airqualitytitle + "\n" |
| 38 | airqualitylabel.config(text=airqualityText) |
| 39 | |
| 40 | weatherPrediction.after(120000, getWeather) |
| 41 | root.update() |
| 42 | |
| 43 | |
| 44 | locationlabel = tk.Label(root, font=("Calibri bold", 20), bg="white") |
no test coverage detected