- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$movie = "http://captainamericacivilwarmovie.pro/";
function scrape($URL){
//cURL options
$options = Array(
CURLOPT_RETURNTRANSFER => TRUE, //return html data in string instead of printing it out on screen
CURLOPT_FOLLOWLOCATION => TRUE, //follow header('Location: location');
CURLOPT_CONNECTTIMEOUT => 60, //max time to try to connect to page
CURLOPT_HEADER => FALSE, //include header
CURLOPT_REFERER => 'http://captainamericacivilwarmovie.pro/',
CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0", //User Agent
CURLOPT_URL => $URL //SET THE URL
);
$ch = curl_init($URL);
curl_setopt_array($ch, $options);
$data = curl_exec($ch);
curl_close($ch);
preg_match_all('/<iframe .* src=\"(.*?)\" .*><\/iframe>/', $data, $matches);
$retData='';
echo '<pre>';
print_r( $matches);
echo '</pre>';
if($matches[1][1] != null){
$retData=$matches[1][1];
}else if($matches[1][0] != null){
$retData=$matches[1][0];
}else $retData='';
echo $retData;
}
scrape($movie);
?>