I want to print the value of an attribute based on its name, e.g.
<META NAME="City" content="Austin">
I want to do something like this
soup = BeautifulSoup(f) //f is some HTML containing the above meta tag for meta_tag in soup('meta'): if meta_tag['name'] == 'City': print meta_tag['content']
The above code gives KeyError: 'name' , I believe this is because the name is used by BeatifulSoup, so it cannot be used as a keyword argument.
python beautifulsoup
Ruth Jun 26 '12 at 10:29 2012-06-26 10:29
source share