
March 10th, 2013, 09:30 PM
|
 |
Contributing User
|
|
|
|
I think you need a better tutorial. The program is too complicated.
Code:
from urllib import urlopen
import re
webpage = urlopen('http://www.kayak.com/h/rss/deals').read()
patFinderTitle = re.compile('<title>(.*)</title>')
titles = patFinderTitle.findall(webpage)
for (i,title,) in enumerate(titles):
print('title %2d: %s'%(i,title,)
Run this program, you'll see there are 8 titles, indexes 0 through 7. With the crazy list iterator you were trying to access the unavailable indexes 8 and 9 causing, appropriately, IndexError.
__________________
[code] Code tags[/code] are essential for python code!
|