question archive When prompting the user you must always include text which lets the user know what should be inputted
Subject:Computer SciencePrice:3.87 Bought7
When prompting the user you must always include text which lets the user know what should be inputted.
Update the weather.py file to do the following:
WEATHER.PY FILE:
import bs4, requests
try:
url = 'https://forecast.weather.gov/MapClick.php?'
latlong = 'lat=46.8837&lon=-102.7817'
# Combines url and zip
res = requests.get(url + latlong)
# Checks for error, and raises it as necessary
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, 'html.parser')
# Select for station
elems = soup.select('#current-conditions > div.panel-heading > div > h2')
# Retrieves station information and prints it out
stationName = elems[0].text
print(stationName)
except Exception as ex:
# Print out any error messages
print('There was a problem retrieving the information')
The following are some urls with the latitude and longitude of weather stations to test your program:
https://forecast.weather.gov/MapClick.php?lat=32.73016&lon=-117.19518
https://forecast.weather.gov/MapClick.php?lat=46.999&lon=-102.8833
https://forecast.weather.gov/MapClick.php?lat=33.417&lon=-111.8315
https://forecast.weather.gov/MapClick.php?lat=41.2607&lon=-95.9403
https://forecast.weather.gov/MapClick.php?lat=30.4391&lon=-81.703
https://forecast.weather.gov/MapClick.php?lat=41.3108&lon=-105.5903
Purchased 7 times