我在php中使用curl获取网站数据,但问题是我无法获得所需的网站数据。它只显示主页数据。
<?php
$url="http://fdating.com/";
function getHTML($url,$timeout)
{
$ch = curl_init($url); // initialize curl with given url
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error
return @curl_exec($ch);
}
$resp=getHTML($url,200);
$xml = simplexml_load_string($resp);
$arr = json_decode( json_encode($xml) , 1);
print_r($arr);
?>