Beautiful Soup Question: Filtering Images based on their width and height attributes

Fredrik Lundh fredrik at pythonware.com
Fri Dec 1 01:42:25 EST 2006


Chris Mellon wrote:

>> 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?
> 
> Most image tags "in the wild" don't have height attributes, you have
> to download the image to see what size it is.

or at least a small portion of it; see the example at the bottom of this 
page for one way to get the size without downloading more than 1k or so:

     http://effbot.org/zone/pil-image-size.htm

</F>




More information about the Python-list mailing list