scrape rss flickr pics (one)

Today, ungodly ones, we scrape flickr-pics with php.

I first checked the normal tag-listing page and you can scrape that one as well but sometimes rss-files are easier. In this case the nice flickr people stuff the image link in a [description] or something, so I have to use preg_match anyway, otherwise i’d use simplexml.

The rss-file has less obsolete stuff in it so I’ll use that one.

$flikker = join("",file("$mytag&format=rss"));
$flikkerhits = preg_split('/img src="\;/', $flikker, -1, PREG_SPLIT_OFFSET_CAPTURE);
foreach($flikkerhits as $flikkerhit){
    if($i>1) echo "";

$mytag is the pictures tag I want
photos_public.gne is the public pictures file
I break up the rss text on [img src="]
that gives me a list starting with all image url’s
all image url parts end with [&quot width’]
so I do a strpos on “width”, and take 7 off
and I got my image url,
add an image tag and I got a basic dump of the images
the first string is crap, so i use a counter to exclude it.

a basic 7 lines flickr rss-scraper, short, I can handle that.

ape beasty …that is a cute ape

on to part two…

Posted in php, tool and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *