Retrieve url's of all jpegs at a web page URL

Chris Rebert clp2 at
Wed Sep 16 01:43:23 CEST 2009

On Tue, Sep 15, 2009 at 7:28 AM, grimmus <graham.colmer at> wrote:
> Hi,
> I would like to achieve something like Facebook has when you post a
> link. It shows images located at the URL you entered so you can choose
> what one to display as a summary.
> I was thinking i could loop through the html of a page with a regex
> and store all the jpeg url's in an array. Then, i could open the
> images one by one and save them as thumbnails with something like
> below.

0. Install BeautifulSoup (

from BeautifulSoup import BeautifulSoup
import urllib

page_url = ""

with urllib.urlopen(page_url) as f:
    soup = BeautifulSoup(
for img_tag in soup.findAll("img"):
    relative_url = img_tag.src
    img_url = make_absolute(relative_url, page_url)

2. Write make_absolute() and save_image_from_url()

3. Profit.


More information about the Python-list mailing list