# Program to get a file at a URL

# Module that knows about URLs
import urllib

# Most of the URL gets to our class folder
ecs10base = "http://www.cs.ucdavis.edu/~amenta/f07/"
# Get the lectures page into a local file of the same name
urllib.urlretrieve(ecs10base+"lectures.html","lectures.html")

infile = open("lectures.html","r")

line = infile.readline()
while line != "":
    # Look for names of Python programs in quotes
    chunks = line.split('"')
    for chunk in chunks:
        # Split all pieces and see if the last piece is .py
        items = chunk.split(".")
        if items[-1] == "py":
            # Found a Python program! Get it off the Web.
            urllib.urlretrieve(ecs10base+chunk,chunk)
    line = infile.readline()

