Hi, i need to take the imdb score of a movie and save it into a table. But i dont have idea how can i take the score. For example for this url: http://www.imdb.com/title/tt0167260/ The score is 8.8/10 So i will aprecciate any help, thanks alot.
function get_imdb_score($url) { if (!($file = file_get_contents($url))) trigger_error('Unable to retrieve page from IMDB', E_USER_ERROR); if (!preg_match('/class="meta">\s*<b>([\d.]+)\/10/', $file, $matches)) trigger_error('Unable to parse IMDB response', E_USER_ERROR); return $matches[1]; } echo 'Score = ' . get_imdb_score('http://www.imdb.com/title/tt0167260/'); Code (markup): Obviously this may stop working whenever IMDB tinkers with their page layout. They may also get bored of you querying them too many times and block you from connecting, so be sure to cache results in your own local database rather than hitting them every time you want to know the same movie's score.
It's always smart to actually check the webpage itself for information. First, data-mining, of any kind, is forbidden by IMDb. You can, however, get access to the data IMDb provides: http://www.imdb.com/help/show_leaf?usedatasoftware http://www.imdb.com/interfaces Mind, the data can be used only for private or non-commercial use - any other uses need to go through IMDb licensing - you can find that information here: http://www.imdb.com/Licensing/