querylist采集数据 模拟滑动验证码 jcapche
1.获取验证码token
2.模拟传入验证码滑动距离 ,经过检测不低于140
private function get_slide_distance($distance,$token){ $cookieArr = $this->get_jar(); $url_capt = "https://*****.cn/gsxt/PlatformSHZZFRKGSXT/slideCaptcha"; $url_check = "https://******.cn/gsxt/PlatformSHZZFRKGSXT/slide_captcha_check"; $url_check .= "?slideCaptchaToken=".$token."&slidecaptcha=".$distance; ; $params1 = [ 'headers' => [ 'Accept' => 'application/json, text/plain, */*', 'Accept-Encoding' => 'gzip, deflate, br', 'Cookie' => $cookieArr[0]['Name'] . "=" . $cookieArr[0]['Value'] . "; " . $cookieArr[1]['Name'] . "=" . $cookieArr[1]['Value'], 'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8', 'Connection' => 'keep-alive', 'Content-Length' => 0, 'Host' => '******.gov.cn', 'Origin' => 'https://******.cn', 'Referer' => 'https://*******.cn/gsxt/newList', //不能去掉 'Sec-Fetch-Dest' => 'empty', 'Sec-Fetch-Mode' => 'cors', 'Sec-Fetch-Site' => 'same-origin', 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36' ] ]; try { $ql = QueryList::get($url_capt,['slideCaptchaToken'=>$token], $params1); } catch (ClientException $e) { echo "<pre>"; echo $e->getRequest(); echo $e->getResponse(); exit(); } /* echo "<pre>"; print_r(json_decode($ql->getHtml())); exit();*/ try { $ql = QueryList::get($url_check,['slideCaptchaToken'=>$token,'slidecaptcha'=>$distance], $params1); } catch (ClientException $e) { echo "<pre>"; echo $e->getRequest(); echo $e->getResponse(); exit(); } $re = json_decode($ql->getHtml()); if($re->code == 200 && $re->result == "success"){ Cache::set('slidecaptcha'.$token,$distance); return $distance; }else{ return $this->get_slide_distance($distance+2,$token); } }