function get_resource()
{
$url3=””;
$ch = curl_init();
// 设置浏览器的特定header
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
“Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8”,
“Accept-Encoding:gzip, deflate, sdch”,
“Accept-Language:zh-CN,zh;q=0.8”,
“Cache-Control:max-age=0”,
“Connection:keep-alive”,
“Cookie:PHPSESSID=046nki081pq1q95i14ri56gm50; __guid=120719246.3657633326262056000.1513052974140.0562; lang=cn; chart_time=5; chart_time_name=chart_5m; chart_theme=white; monitor_count=30”,
“Host:www.xxx.com”,
“Upgrade-Insecure-Requests:1”,
“User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36”
));
curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0’);
// 在HTTP请求头中”Referer: “的内容。
curl_setopt($ch, CURLOPT_REFERER,”http://www.xxx.com”);
curl_setopt($ch, CURLOPT_ENCODING, “gzip, deflate, sdch”);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url3);
curl_setopt($ch, CURLOPT_TIMEOUT,120);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//302redirect
$html = curl_exec($ch);
curl_close($ch);
return $html;
}//get_resource结束
$t3=json_decode(get_resource(),TRUE); //返回数组