stealing images from IMDB

If you touch your software enough does it become hardware?

Moderator: Forum Moderators

Post Reply
ProfHawking
Zombie
Zombie
Posts: 2101
Joined: February 20th, 2005, 21:31

stealing images from IMDB

Post by ProfHawking »

Im trying to write a movie archive scripty thing in php.
i have got it pulling lots of details from imdb when given a film title, however getting the poster images is proving fiddly.

This works, kinda:

Code: Select all

$this->poster		= trim($this->getMatch('|<div class="photo">(.*)</div>|Uis', $imdb_content));
for example, it returns:

Code: Select all

<a name="poster" href="/rg/action-box-title/primary-photo/media/rm2762448640/tt0092067" title="Tenkû no shiro Rapyuta"><img alt="Tenkû no shiro Rapyuta" title="Tenkû no shiro Rapyuta" src="http://ia.media-imdb.com/images/M/MV5BMTU4MTUyMTc3MV5BMl5BanBnXkFtZTYwOTg4Mzk5._V1._SX98_SY140_.jpg" border="0"></a>
on sky blue.

All i want it to return is the image source:

Code: Select all

http://ia.media-imdb.com/images/M/MV5BMTU4MTUyMTc3MV5BMl5BanBnXkFtZTYwOTg4Mzk5._V1._SX98_SY140_.jpg

Anyone know how i can get it to do this?
buzzmong
Weighted Storage Cube
Weighted Storage Cube
Posts: 7167
Joined: February 26th, 2007, 17:26
Location: Middle England, nearish Cov

Post by buzzmong »

I'd just go with some string manipulation on the outputted string narf, shouldn't be too much effort to get php to find the src=" in the string and return it to either overwrite the var or assign to a new one. The explode function might come in useful.

I've not done php since last year, and even then I was mostly doing DB calls and some basic formatting.
Last edited by buzzmong on November 8th, 2008, 23:31, edited 1 time in total.
Stoat
Site Admin
Site Admin
Posts: 3291
Joined: October 8th, 2004, 15:48
Location: Sheffield, UK
Contact:

Post by Stoat »

You can just Regex the source out of it can't you? It starts with 'http://ia.media-imdb.com/images/' and ends with '.jpg' so extracting the url should be easy enough with preg_match.
Fear
Zombie
Zombie
Posts: 2032
Joined: August 6th, 2006, 21:45

Post by Fear »

What stoat said. :above:

Code: Select all

http://ia\.media-imdb\.com/images/.+?\.(?:jpg|gif|jpeg|png)
Something like that perhaps.
Post Reply