I am trying to extract the contents of a single value attribute in a particular input tag on a web page. I am using the following code:
import urllib f = urllib.urlopen("http://58.68.130.147") s = f.read() f.close() from BeautifulSoup import BeautifulStoneSoup soup = BeautifulStoneSoup(s) inputTag = soup.findAll(attrs={"name" : "stainfo"}) output = inputTag['value'] print str(output)
I get TypeError: list indices should be integers, not str
although from the Beautifulsoup documentation I understand that strings should not be a problem here ... but I am not a specialist and I may have misunderstood.
Any suggestion is much appreciated! Thanks in advance.
python parsing attributes beautifulsoup
Barnabe Apr 10 '10 at 6:53 2010-04-10 06:53
source share