Use lxml and CSS selectors
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml.html import document_fromstring
>>> doc = """<html>
... <body>
... <div class="pictures">
... <img src="http://some.unknownaddress.com/random_image1.jpg" alt="" class="image" height="123" width="123">
... <img src="http://some.unknownaddress.com/random_image2.jpg" alt="" class="image" height="123" width="123">
... </div>
... <div class="pictures">
... <img src="http://some.unknownaddress.com/random_image3.jpg" alt="" class="image" height="123" width="123">
... <img src="http://some.unknownaddress.com/random_image4.jpg" alt="" class="image" height="123" width="123">
... </div>
... </body>
... </html>"""
>>> html = document_fromstring(doc)
>>> html.cssselect(".pictures img")
[<Element img at 0x2423f00>, <Element img at 0x242f2d0>, <Element img at 0x242f150>, <Element img at 0x242f210>]
>>> print "\n".join(x.attrib['src'] for x in html.cssselect(".pictures img"))
http://some.unknownaddress.com/random_image1.jpg
http://some.unknownaddress.com/random_image2.jpg
http://some.unknownaddress.com/random_image3.jpg
http://some.unknownaddress.com/random_image4.jpg
Or XPath:
>>> html.xpath("//div[@class='pictures']/img")
[<Element img at 0x2787c60>, <Element img at 0x2787c90>, <Element img at 0x2787cf0>, <Element img at 0x242f210>]
>>> print "\n".join(html.xpath("//div[@class='pictures']/img/@src"))
http://some.unknownaddress.com/random_image1.jpg
http://some.unknownaddress.com/random_image2.jpg
http://some.unknownaddress.com/random_image3.jpg
http://some.unknownaddress.com/random_image4.jpg