我正在获取远程页面的源代码它从用户根据数组单击的 url 动态获取的远程页面的 url array('event_id', 'tv_id', 'tid', 'channel')
:我使用下面的代码来获取 who;e 页面源,它工作得很好。
<?php
$keys = array('event_id', 'tv_id', 'tid', 'channel'); // order does matter
$newurl = 'http://lsh.streamhunter.eu/static/popups/';
foreach ($keys as $key)
$newurl.= empty($_REQUEST[$key])?0:$_REQUEST[$key];
$newurl.='.html';
function get_data($newurl)
{
$ch = curl_init();
$timeout = 5;
//$userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.X.Y.Z Safari/525.13.";
$userAgent = "IE 7 – Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)";
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch,CURLOPT_URL,$newurl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$html = get_data($newurl);
echo $html
?>
这里的诀窍是我只想回显代码的第 59 行怎么做?