时间:2021-07-01 10:21:17 帮助过:16人阅读
$parm=$data['parm']."&_=".time()."326"; //参数 $ch= curl_init(); $uri="http://www.131458.com/handler/TaobaoInfo.ashx?"; curl_setopt($ch, CURLOPT_URL, $uri.$parm); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_REFERER, "http://www.131458.com/"); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:125.67.52.246', 'CLIENT-IP:125.67.52.246')); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 SE 2.X MetaSr 1.0"); / $return = curl_exec($ch); curl_close($ch); echo $return;
抓包看看呢?一般都是header里面需要啥,就都传过去
首先,你的方法不对,则是chrome F12下跟踪的结果,CURL命令如下:
curl "http://www.131458.com/handler/TaobaoInfo.ashx?tbNickInfoJson=hades&token=736905fff9ee639a4b5f46b53526434b_0b32d3aec47ad29fef2d7ddb67831933&_=1447405734036" -H "Cookie: ASP.NET_SessionId=4ki3s2yhj2555bzxlbvdqhju; Hm_lvt_ccc93bebd5e7bdc84975186073891702=1447405635; Hm_lpvt_ccc93bebd5e7bdc84975186073891702=1447405635; bdshare_firstime=1447405634805" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: zh-CN,zh;q=0.8" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Referer: http://www.131458.com/" -H "X-Requested-With: XMLHttpRequest" -H "Connection: keep-alive" --compressed
一次不好完成的curl.
截图:
escape($tb_nick_name));$url = 'http://www.131458.com/handler/load.aspx/Load';// 初始化$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($post));curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file);curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);$response = curl_exec($curl);curl_close($curl);$d = json_decode($response)->d;$_token = md5($d . 'vvl81');$url = 'http://www.131458.com/handler/TaobaoInfo.ashx?nickCode=' . escape($tb_nick_name) . '&token=' . $_token . '_' . $d . '&_=' . time() . rand(100, 999);$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);$contents = curl_exec($curl);curl_close($curl);/* * $preg = "/