curl模拟ip段访问

来源:互联网 发布:数据库启停 编辑:程序博客网 时间:2024/06/05 18:20

申明:本实例仅供学习使用,不做任何商业用途,如因此引起任何法律纠纷,本博客不承担任何责任

header("Content-type: text/html; charset=utf-8");$id = isset($_GET['id'])?$_GET['id']:exit('no params');function curl($destURL, $paramStr='',$flag='get',$ip='10.57.22.151',$fromurl='http://www.baidu.com'){  if(!extension_loaded('curl')) exit('系统没有扩展php_curl.dll,出错了。');$curl = curl_init(); if($flag=='post'){//post传递curl_setopt($curl, CURLOPT_POST, 1);               curl_setopt($curl, CURLOPT_POSTFIELDS, $paramStr); }curl_setopt($curl, CURLOPT_URL, $destURL);//地址curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip));  //构造IP  curl_setopt($curl, CURLOPT_REFERER, $fromurl); curl_setopt($curl, CURLOPT_TIMEOUT, 10);#10s超时时间curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);$str = curl_exec($curl);curl_close($curl);return $str;}$output = curl("http://code.bankrate.com.cn/getProductData/financing_{$id}?pos=detail",'','get',"60.166.0.3","http://www.bankrate.com.cn/financing/{$id}");$match = array();preg_match_all('/{(.*)}/',$output,$match);$str = $match[0][0];$arrTmp = json_decode($str,true);print_r($arrTmp['data'][503]);exit();//IP地址段 60.166.0.0 60.166.16.158for($i=0;$i<=100;$i++){$getip='60.166.'.rand(0,16).'.'.rand(0,158) ;echo curl("http://code.bankrate.com.cn/getProductData/financing_{$id}?pos=detail",'','get',$getip," http://www.bankrate.com.cn/financing/{$id}");}exit();


原创粉丝点击