Skip to content

Commit fa2d900

Browse files
committed
update extracting weather data code
1 parent 3073403 commit fa2d900

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: web-scraping/weather-extractor/weather.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from bs4 import BeautifulSoup as bs
33
import requests
44

5-
USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36"
5+
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"
66
# US english
77
LANGUAGE = "en-US,en;q=0.5"
88

@@ -35,7 +35,7 @@ def get_weather_data(url):
3535
days = soup.find("div", attrs={"id": "wob_dp"})
3636
for day in days.findAll("div", attrs={"class": "wob_df"}):
3737
# extract the name of the day
38-
day_name = day.find("div", attrs={"class": "vk_lgy"}).attrs['aria-label']
38+
day_name = day.findAll("div")[0].attrs['aria-label']
3939
# get weather status for that day
4040
weather = day.find("img").attrs["alt"]
4141
temp = day.findAll("span", {"class": "wob_t"})

0 commit comments

Comments
 (0)