Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa2d900

Browse files
committed
update extracting weather data code
1 parent3073403 commitfa2d900

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎web-scraping/weather-extractor/weather.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
frombs4importBeautifulSoupasbs
33
importrequests
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
fordayindays.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)

[8]ページ先頭

©2009-2025 Movatter.jp