21,887
社区成员
发帖
与我相关
我的任务
分享
$content=file_get_contents('http://istock.jrj.com.cn/d/ht/hottopic1.html');
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: Mozilla/5.0\n"
)
);
$context = stream_context_create($opts);
echo file_get_contents("http://istock.jrj.com.cn/d/ht/hottopic1.html",false,$context);
$queryURL = "http://istock.jrj.com.cn/d/ht/hottopic1.html";
//user_agent
$useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
//伪造header
$header = array('Accept-Language: zh-cn','Connection: Keep-Alive','Cache-Control: no-cache');
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, $queryURL);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_URL,$queryURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo $result;