Hi there , there's a movies review site and i want to write a code so i will be able to pull only the review part from the movie's page every movie has its own page and thats how it looks like : Movie's name pic actors review producer etc... I want to pull only the "review" section , i know i can use "file get contents" , but how can i pull only the review section each time ?
look for a standard string before and after the text that you want to pull, then extract it from the text you get using the file_get_contents function. for example: $whole_text = file_get_contents("file.html"); $start_string = "Reviews:";//could be any thing else, even html code but must be unique $end_string = "end review";//look comment for $start_string $review = get_string_between($whole_text, $start_string , $end_string); //and dont worry, this is the get_string_between function :) function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } PHP:
Always keep an eye on your page because, if the movie page layout changes, your page may need new standard strings. Remember too that each time someone views your page your server downloads a copy of the movie page. If it becomes too popular the movie site may become angry with you due to the extra bandwidth (especially since you are essentially taking their content too).
Is there not a way around this, for example couldn't you pull the data then store it in your own database and retrieve it from there.
storing the data on my own database is an option too anyway i just wanna do it for practicing , i hope ill be able to use it in the future