php curl 抓取数据伪装

<p>php curl伪装抓取</p><pre class="brush:php;toolbar:false">$ch=curl_init($url); curl_setopt($ch,CURLOPT_HEADER,0);//过滤HTTP头 curl_setopt($ch,CURLOPT_TIMEOUT,40); curl_setopt($ch,CURLOPT_USERAGENT,&#39;Baiduspider+(+http://www.baidu.com/search/spider.htm)&#39;); $ip=&#39;220.181.7.121&#39;; curl_setopt($ch,CURLOPT_HTTPHEADER,array(&#39;X-FORWARDED-FOR:&#39;.$ip,&#39;CLIENT-IP:&#39;.$ip)); curl_setopt($ch,CURLOPT_REFERER,&quot;http://www.baidu.com/search/spider.html&quot;); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//显示输出结果 $responseText=curl_exec($ch); curl_close($ch);</pre>
RangeTime:0.005337s
RangeMem:204.17 KB
返回顶部 留言