在浏览器中访问远程数据是下截提示,但用f12查看是可以的,但php程序用curl和file_get_contents 读取的话,是出现乱吗,不知道有什么办法可以读取http://115.239.217.67/appsrv?abi=armeabi-v7a&type=soft&network=WF&catestrategy=adv&cen=cuid_cut_cua_uid&platform_version_id=19&action=catelist&apn=&getsubcate=1&sorttype=hot&psize=3&cid=503&pkname=com.baidu.appsearch&country=CN&gms=false&pu=cua%40_a-qi4uq-igBNE6lI5me6NIy2IYUh2NlgI2cfAqqC%2Cosname%40baiduappsearch%2Cctv%401%2Ccfrom%401011454o%2Ccuid%400iH3uliCHf_u8vig_av_a0aJSigTi2uA0PSuiguqSa6muviJ0u2gi_as28_Euv8uja20fqqqB%2Ccut%405fXCirktSh_Uh2IJgNvHtyN6moi5pQqAC&language=zh&native_api=1&pn=0
这个是远程地址
这个是远程地址
CURLOPT_USERAGENT
CURLOPT_REFERER
CURLOPT_ENCODING
参数
CURLOPT_COOKIEJAR
还要加这两个
$cookiejar = realpath('cookie.txt');
$t = parse_url($durl);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$durl);
curl_setopt($ch, CURLOPT_TIMEOUT,5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/");
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_ENCODING, 1); //gzip 解码
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if($data) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
$r = curl_exec($ch);
curl_close($ch);
return $r;
}调用
$s= curl_get($url);