CS 2204 Lab 10
Your name here (please print):
Your student ID number here:
- (1 point). Go to http://www.weather.com and get local current weather for Blacksburg (zip 24060). In your browser go to "View" and select "page source". Figure out where the temperature information is located.
- (1 point) Identify what URL needs to be specified for the above page and write a bash script that fetches it to a file named "page". Follow
the stock price example from last class.
Verify that the page you get is the same as in 1).
- (2 points) Put a check in your script that verifies that at least a single argument is given. If not, the script exits.
- (2 points) Add a check that verifies each argument to be a valid US zip code (e.g 132 or 786443 are not valid US zips ).
- (4 points) Wrap up by making your script output current weather (in degrees F) for any number of valid zip codes given as the arguments. You may find the last lecture and Lab 9, #2 useful. If substr does not help,
you may also play
with gsub function of gawk to get rid of the "stuff"
around the number you are after.
The output should look like: "Currently, it is xx degrees F in location yyyyy" (yyyyy -- the entered zip).
- (bonus 2 points) Make the above script output a more user-friendly line:
"Currently, it is xx degrees F in Blacksburg, VA" (where the city automatically corresponds to the zip entered ).