CSC 111: Introduction to Computer Science
HW 9: More HTML
Due Wednesday April 13 Midnight, via Moodle
SUBMIT as HW9.py VIA MOODLE
You can also upload your .html file (and any figures you want) to the new public_html folders used in lab, but those are
strictly for your own entertainment. I will grade whatever you submit via Moodle.
Part 1: Complete all the elements from lab as part of your homework
- Make sure all your files are neat, clearly organized and easy to read.
- Have an HTML list somewhere on your page, having used a Python loop to create it.
- Include a horoscope and the date that the horoscope was retrieved, using the code from class, that you completed in lab.
Part 2: Retrieve and Include the Weather
This is your chance to apply a lot of your new skills. Using the Weather Underground URL:
http://www.wunderground.com/
- Enter a zip code, and see what happens to the URL in the banner
- Go back to the original URL and enter a different zip code - what happens now to the URL?
- Try editing the URL directly with yet another zip code.
(2a) Getting Started - Edit the Class Example
Once you are comfortable with how the URL works, try editing the
first horoscope example from class, to simply create and display the desired weather URL -- just the URL string itself, NOT the html text yet.
In this getHoros1.py file, you should change the function name and all the variable names now (and of course the Python filename), so that they make
sense for retrieving the weather, rather than for retrieving a horoscope.
(2b) Identifying Your Markers and Extract Text
Now you want to work on extracting the desired weather information. The URL above will provide you with:
- Current conditions, such as "Partly Cloudy," "Clear," "Scattered Clouds," etc.
- The current temperature.
- The town name associated with the zipcode that was entered.
Your task is to identify markers for all three of these pieces of information and extract this information from the weather html text. Put all of this
new Python code, performing this new task, into its own function - a function to open the weather URL and retrieve the desired HTML weather related text.
(2c) Write Place, Conditions and Temp to Your Webpage - A NEW Function
Finally, in yet ANOTHER NEW FUNCTION, write this weather related information to your html file that will be your beautiful web page. For example,
if you were to enter the zip code of 01063, your web page would include text letting the viewer know the current conditions and the temperature
for Northampton, MA.
Part 3: Grading, aka "How I will run your program"
The program you submit, via Moodle (I will not grade anything in the public_html directories on the Computer Science servers), must request two
pieces of information from the user, and only two pieces. These must be any zodiac sign, and any zip code. The user must be able to type the zodiac sign
with any crazy combination of upper case and lower case characters, and have your program still function properly.
Thus, for Capricorn, the user should be able to enter CAPriCOrN, Capricorn, capricorn, capRICorn, (you get the idea), and your program should
work the same. This means that not only should the URL open fine, but also, whatever you print out on your webpage should be fixed so that the
zodiac sign is nicely capitalized, without other crazy uppercase letters used.
To summarize:
- Submit your program via Moodle, as usual.
- I will expect to enter a zodiac sign and a zipcode to run your program, any zodiac and zipcode that I think of.
- I will not enter anything else, so don't have your program ask me for any other information.
- As with HW8, rename any figures you use to be simply "HW9image.jpg" (or you can use "HW8image.jpg" - I'll have one of each in
my directory).
You can of course put any version of your webpage that you want into the public_html directory for anyone on the Web to view.