php-我用了curl代理,为什么抓取http://www.ip138.com 显示的还是实际ip
程序员文章站
2022-04-08 17:57:11
...
phpcurl
我在 http://ip.qiaodm.com/上面找的高匿代理
这是我的代码我curl用了代理ip做抓取,按理说应该显示的是我代理的ip但是还是显示的我的本机IP。 有谁知道为什么
function get_html($url,$data=array(),$html_char='UTF-8',$is_ssh='http'){
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_PROXY,'111.12.117.67'); curl_setopt($ch, CURLOPT_PROXYPORT,'83'); curl_setopt ($ch, CURLOPT_HTTPHEADER, array('CLIENT-IP:113.207.63.26', 'X-FORWARDED-FOR:113.207.63.26')); curl_setopt ($ch, CURLOPT_TIMEOUT, 6000); curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0'); if($is_ssh=='SSL'){ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); if(!empty($data)){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } $output = curl_exec($ch); if($html_char!='UTF-8'){ $output=mb_convert_encoding($output, "UTF-8", $html_char); } $info = curl_getinfo($ch); curl_close($ch); $returntemp = array('output'=>$output,'info'=>$info); return $returntemp['output']; }
$url='http://www.ip138.com/';
$date=get_html($url);
echo $date;