Skip to content

Commit 3e4cd79

Browse files
authored
Merge pull request mikeckennedy#26 from mikeckennedy/app-5-fix-new-design-wunderground
Fixes due to change in wunderground.com html structure.
2 parents a302216 + afb1b98 commit 3e4cd79

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apps/05_weather_client/final/program.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ def get_html_from_web(zipcode):
4949

5050

5151
def get_weather_from_html(html):
52-
# cityCss = 'div#location h1'
53-
# weatherConditionCss = 'div#curCond span.wx-value'
54-
# weatherTempCss = 'div#curTemp span.wx-data span.wx-value'
55-
# weatherScaleCss = 'div#curTemp span.wx-data span.wx-unit'
52+
# cityCss = '.region-content-header h1'
53+
# weatherScaleCss = '.wu-unit-temperature .wu-label'
54+
# weatherTempCss = '.wu-unit-temperature .wu-value'
55+
# weatherConditionCss = '.condition-icon'
5656

5757
soup = bs4.BeautifulSoup(html, 'html.parser')
58-
loc = soup.find(id='location').find('h1').get_text()
59-
condition = soup.find(id='curCond').find(class_='wx-value').get_text()
60-
temp = soup.find(id='curTemp').find(class_='wx-value').get_text()
61-
scale = soup.find(id='curTemp').find(class_='wx-unit').get_text()
58+
loc = soup.find(class_='region-content-header').find('h1').get_text()
59+
condition = soup.find(class_='condition-icon').get_text()
60+
temp = soup.find(class_='wu-unit-temperature').find(class_='wu-value').get_text()
61+
scale = soup.find(class_='wu-unit-temperature').find(class_='wu-label').get_text()
6262

6363
loc = cleanup_text(loc)
6464
loc = find_city_and_state_from_location(loc)

0 commit comments

Comments
 (0)