Beautiful Soup Question: Filtering Images based on their width and height attributes
David Coffin
dcoffin at gmail.com
Mon Dec 4 08:00:58 EST 2006
> Hello,
>
> I want to extract some image links from different html pages, in
> particular i want extract those image tags which height values are
> greater than 200. Is there an elegant way in BeautifulSoup to do this?
Yes.
soup.findAll(lambda tag: tag.name=="img" and tag.has_key("height")
and int(tag["height"]) > 200)
More information about the Python-list
mailing list