您好,欢迎访问一九零五行业门户网

curl爬教务系统的数据解决思路

curl爬教务系统的数据
你好各位又来请教大家了,我现在又遇到这样的情况
代码是这样子的
function search3($id,$year, $term, $ch,$value){
//$data=file_get_contents(d://value.txt);
curl_setopt ( $ch, curlopt_proxy, 'jackdowosn.gnway.net:81');
$curlpost = xh=k061141026&__viewstate=$value&button2=按学年学期查询&ddlkclx=必修&xn=2012-2013&xq=1;
$curlpost = iconv(utf-8, gbk, $curlpost);
curl_setopt ( $ch, curlopt_useragent, mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.1) gecko/20061204 firefox/4);
curl_setopt ( $ch, curlopt_followlocation,true);
curl_setopt ( $ch, curlopt_url, http://211.67.32.51/xscj.aspx );
curl_setopt ( $ch, curlopt_header, 0);
curl_setopt ( $ch, curlopt_returntransfer, 1 );
curl_setopt ( $ch, curlopt_post, 1 );
curl_setopt ( $ch, curlopt_referer, http://211.67.32.51/xscj.aspx?xh=k061141026 );
curl_setopt ( $ch, curlopt_postfields, $curlpost );
curl_setopt ( $ch, curlopt_cookiefile, $cookiejar ); // 要回传cookie
$data = curl_exec ( $ch );
curl_close ( $ch );
$data = mb_convert_encoding ( $data, utf-8, gbk );
/*preg_match_all ( '/\\s*\(.*?)\\s*\ (.*?)\/is', $data, $matches );
foreach ( $matches [1] as $key => $val )
$nav =$nav .\n. $val . --- . $matches [2] [$key];*/
return $data;
}
以上程序执行到search3时出现了,其他的都可正常返回数据。我问过一个前辈,他的回答是“我也不清楚喔。我有印象我们做正方系统遇到这种问题有可能是参数传错了,有可能是编码错了,也有可能没设置referer这个参数”。请大家帮我看下问题出在哪里,有兴趣的可以帮我调试下,代理服务器都是真实可用的。下面是几个post参数和头信息
其它类似信息

推荐信息