I have the following code:
f = open(path, 'r') html = f.read() # no parameters => reads to eof and returns string soup = BeautifulSoup(html) schoolname = soup.findAll(attrs={'id':'ctl00_ContentPlaceHolder1_SchoolProfileUserControl_SchoolHeaderLabel'}) print schoolname
which gives:
[<span id="ctl00_ContentPlaceHolder1_SchoolProfileUserControl_SchoolHeaderLabel">AB Paterson College, Arundel, QLD</span>]
when I try to access a value (i.e. "AB Paterson College, Arundel, QLD) using schoolname['value'] , I get the following error:
print schoolname['value'] TypeError: list indices must be integers, not str
What am I doing wrong to get this value?
python beautifulsoup
Seth Apr 11 '10 at 10:05
source share