I should also add that once your code starts to become complex, it's best to move away from the interactive interpreter. The code below is essentially the same as detailed above in my previous post. Take this code and put it in a text file, and rename the text file so it has the ".py" extension. Then click on the file and the Python code will be executed automatically.
from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
html = urlopen("http://biz.yahoo.com/ic/ind_index.html")
soup = BeautifulSoup(html)
links = soup.fetch("table")[7].fetch("a")
for link in links:
title = link.string.replace("\n", " ")
print title, "-", link['href']
print
raw_input("Please press enter to quit...") The raw_input at the end makes sure that the CMD window does not close down immediately, but gives you time to read the output.