Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMDB rating using cURL and PHP
#1
A script to find the rating of any imdb movie.

How to use,

php imdb.php <movie name>

Ex :

$ php imdb.php trtanic
Your movie Titanic (1997) has 7.6 ratings.

PHP Code:
<?php
///////////////////////////////////////////////
////////  Author : Sarvsav Sharma  ///////////
//////// Email : sarvsav@gmail.com //////////
////////////////////////////////////////////
$characters count($argv)-1;
if(isset(
$argv[1]))
$movie_name=$argv[1]."+";
else
exit(
0);
for(
$i=2;$i<$characters+1;$i++)
$movie_name.= $argv[$i]."+";
$ch curl_init();
curl_setopt($ch,CURLOPT_URL,'https://www.google.co.in/search?q='.$movie_name.'imdb');
curl_setopt($chCURLOPT_RETURNTRANSFER1);
$movie_link curl_exec($ch);
preg_match('#www\.imdb\.com\/title\/tt\d+#',$movie_link,$matchme);
$imdb_url $matchme[0];
curl_setopt($ch,CURLOPT_URL,$imdb_url."/");
$movie_data =  curl_exec($ch);
curl_close($ch);
preg_match('#ratingValue\"\>\d\.\d#',$movie_data,$matches);
$rating explode(">",$matches[0]);
$name $movie_data;
preg_match('#<title>.+</title>#',$name,$name_match);
$name_match explode(")",$name_match[0]);
$name_match explode(">",$name_match[0]);
echo 
"Your movie ".$name_match[1].") "."has ".$rating[1]." ratings.\n";

?>

Skype : Sarvsav Sharma
Reply
#2
Looks good - looks like you've got a good script here.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 936 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,660 10-10-2011, 01:00 PM
Last Post: Greyersting
  [CODE] Update Twitter using cURL and PHP Jamza 4 2,281 02-23-2011, 12:07 AM
Last Post: sup_hlw

Forum Jump:


Users browsing this thread: 1 Guest(s)