'''A simple way to get the contents of a web page via Python. For more information, see "How not to fetch data over HTTP" at http://www.diveintopython.org/http_web_services/review.html. For the CS257 assignment, you don't have to heed the advice of the author of this web page, but it's worthwhile reading nonetheless. ''' import urllib # Open it, read it, close it. Nice and easy. url = urllib.urlopen('http://cs.carleton.edu/faculty/jondich/courses/cs257_s07/index.html') pageContents = url.read() print pageContents url.close() # You can use the return value of urllib.urlopen like any other # file object. url = urllib.urlopen('http://cs.carleton.edu/faculty/jondich/courses/cs257_s07/index.html') for line in url: line = line.upper() print line, url.close()