Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (120 points)
import requests
from bs4 import BeautifulSoup

page = requests.get('https://forecast.weather.gov/MapClick.php?lat=45.2541&lon=-113.2262#.Xn8kMIgzZPY')
soup = BeautifulSoup(page.content, 'html.parser')
#print(soup)
week = soup.find(id='seven-day-forecast-body')

items = week.find_all(class_='tombstone-container')


period_names = [items.find(class_='period-name').get_text() for item in items]
short_descriptions = [items.find(class_='short-desc').get_text() for item in items]
temperatures = [items.find(class_='temp').get_text() for item in items]

print(period_names)
print(short_descriptions)
print(temperatures)

Please log in or register to answer this question.

Browse Categories

...