I’m pretty avid user of Last.FM. I’m not big on this social networking fad, even if I do work in the industry, but I’ve found Last.FM very useful, mainly for finding new music. I’m currently building a web-based media manger in PHP and wanted a way to automatically get images for the artists.
I originally used the discogs.com API and although it was pretty easy to use and reasonably comprehensive, I was really disappointed in the quality of the images, not to mention I was constantly getting back images of electronic and ambient artists who had names similar to the rock bands in my collection, rather than the rock band themselves. I’m sorry, but when make a call to get images for “Cream” I don’t expect to get back some 14-year-old kid with a turntable and a DAT machine; I want freaking Clapton, Bruce, and Baker.
So, discogs.com left me a bit cold. But I soon learned about Last.FM and was delighted when I discovered their API. The image quality at Last.FM is superb, so I knew I wouldn’t be disappointed there. I started researching their API and realized that they didn’t really give me any info I needed other than the images and I didn’t want to have to sign up for an API key if all I wanted to do was download pictures of bands. Also, they only appear to provide three sizes of images and for many bands they have a whole slew of images available: large, medium, small, smaller, square; I wanted them all, not just the three provided by their API.
So, in the end I decided not to sign up for a Last.FM API key and instead wrote a very simple little PHP screen scraper that would bring back all of the images I wanted. Last.FM actually aided me in my goal by embedding a JSON string with just exactly what I needed right onto the artist page. It worked very well, so I decided to stick with it.
You can download my simple screen scraper script here. The zip file includes the class file and an example file.
It’ an incredibly simple script. Just a basic class file with only one useable method. It’s written so it can be expanded, but as Last.FM’s API is under constant development, it probably won’t be. But if you just want a simple script to grab artist images from Last.FM, please download my script and let me know if you like it.

September 6th, 2008 at 11:46 pm
Hi Nick
Thanks a lot for writing such an cool short script to achieve this simple task. I have an array of few artists, I tried your script to bring me the image urls with the following code,
$artists = array (‘cher’, ‘madonna’, ‘backstreet boys’, ‘boyzone’ , ‘britney spears’);
foreach($artists as $artist){
$images = $lastfm->getArtistImages($artist);
echo $images ,”";
}
but the above code took around 30 seconds to complete the operation which is I think not feasible at all. I want to know that is there any way to load all artists’ images in a single request?
Thanks
September 2nd, 2009 at 8:57 am
hey nick,
thx for the great plugin.
i’d like to know how i can integrate that plugin into wordpress and how i can rate the artist via custom field in a post.
i’d need that for the band and review archive.
thanx
hendrik
October 13th, 2009 at 11:28 am
Hi Hendrik,
Sorry for the delayed response. You just asked a mouthful there, heh. The script I wrote is very simple and just scrapes the images right off the artist page. As far as going further with it and building more integration with the Last.FM API, the sky’s the limit.
It’ll just take a little more familiarity on your part with the different systems (WordPress/Last.FM) to get that sort of thing working. I’d be more than happy to help out.
October 27th, 2009 at 3:15 pm
Interesting point on screen scrapers, I use python for simple html screen scrapers, but for larger projects i used extractingdata.com http://www.extractingdata.com/screen%20scraper.htm which worked great, they build custom screen scrapers and data extracting programs
October 27th, 2009 at 3:31 pm
You know what, Sara, I think you might be a bot … or someone paid to comment on screen-scraper related posts. If you’re a bot, you’re an impressive one, if you’re a paid employee, you have moxie, and if you just really like extractingdata.com for their screen-scraping offerings and felt the need to comment about them here … then I think you might be a little weird.
In any case, I’m letting the comment stand.