473,385 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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?

Nov 30 '06 #1
3 3088
On 30 Nov 2006 12:43:45 -0800, PicURLPy <fb********@gmail.comwrote:
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?
Most image tags "in the wild" don't have height attributes, you have
to download the image to see what size it is.
--
http://mail.python.org/mailman/listinfo/python-list
Nov 30 '06 #2
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>

Dec 1 '06 #3
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)
Dec 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: | last post by:
Hello all, This is an IE6 question: When I click on an image file on my desktop, ie will automatically resize the image to fit the window. But, when I use html to load the image, i.e. <img...
6
by: Robert J. O'Hara | last post by:
I'm one of those people who practices what some consider "dull" and others consider "elegantly conservative" page design. I appreciate good traditional typography and standards-compliant liquid...
2
by: Van der Weij | last post by:
Hi, I want to preload some images for a webpage _and_ determing their width and height. The problem is that the scripts continue while the images are loaded in the background, while I need the...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
3
by: rh0dium | last post by:
Hi all, I am trying to parse into a dictionary a table and I am having all kinds of fun. Can someone please help me out. What I want is this: dic={'Division Code':'SALS','Employee':'LOO...
2
by: no one | last post by:
Hi, I want to write a pearl script that will go out to a web site and download the page. Then pull certain value pairs out of it. Basically I want to see graphs of snr etc. Is grabbing the...
15
by: Francach | last post by:
Hi, I'm trying to use the Beautiful Soup package to parse through the "bookmarks.html" file which Firefox exports all your bookmarks into. I've been struggling with the documentation trying to...
0
by: Samy | last post by:
Hi There, I am trying to display images in a gridview and display only valid images from the html in the database (and not display spacers, 1x1 pixel images etc). For this, I have a gridview...
0
by: Romulo NF | last post by:
Greetings again everyone Recently i´ve been asked to develop a script to allow filtering in the content of the table, with dinamic options based on the own content. Example: a table with the name of...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.