时间:2021-07-01 10:21:17 帮助过:7人阅读
分两次/多次抓取
其实对于ajax/验证码等等都是这样做的
header("Content-type:text/html;charset=utf-8"); function request_by_curl($remote_server, $post_string) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $remote_server); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_NOBODY, false); curl_setopt($ch, CURLOPT_HEADER,true); curl_setopt($ch, CURLOPT_HTTPHEADER, array()); $data = curl_exec($ch); curl_close($ch); return $data; } //获取验证码 file_get_contents("http://jysx.scnu.edu.cn/VerifyImg.aspx"); $cookie = $http_response_header[6]; $code = substr($cookie,23,4); echo $code."
"; //post登录 $remote_server = "http://jysx.scnu.edu.cn/login.aspx"; $post_string = 'act=login&type=ajax&name=20102301025&pass=523523&verify='.$code; echo request_by_curl($remote_server,$post_string);
可以了!!!!!
为什么这个网站会把验证码写到头信息里??