分类:PHP 发布时间:2018-03-06 18:43:00
通过伪造 headers 数据来绕过网站的访问限制,这里以同花顺为例 ``` $url = 'http://q.10jqka.com.cn/dy/index/field/199112/order/desc/page/1/ajax/1/'; //构建请求头数据 $curl_header = array( 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1 )', 'Accept-Encoding:gzip, deflate', 'Cookie: hxmPid=free_stock_jiankuang_600971; Hm_lvt_78c58f01938e4d866af619eae71b4ed1=1516670596,1516774134,1517466256; v=ApegrBNDgWH78gXtFjsfJ8qPJgDl3Gs-RbDvsunEs2bNGL328az7jlWAfwf7', 'Host:q.10jqka.com.cn', ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11"); curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_header); // curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($curl, CURLOPT_REFERER, "http://q.10jqka.com.cn/"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT,30); curl_setopt($curl, CURLOPT_ENCODING, ""); $resultData = curl_exec($curl); curl_close($curl); ```
搜索
文章分类
最新文章