Try logging in with curl today and enter the verification code manually. Question and how can I use curl to simulate form login with image verification code? Similarly, my question is, how can I get a session or set a session when pulling an image? (The first answer to that question is not correct. Try logging in with curl today and enter the verification code manually.
Question and how can I use curl to simulate form login with image verification code? Similar
My question is, how can I get the session or set it when I pull the image?
(The first answer to that question is not correct)
Please help me.
Reply content:
Try logging in with curl today and enter the verification code manually.
Question and how can I use curl to simulate form login with image verification code? Similar
My question is, how can I get the session or set it when I pull the image?
(The first answer to that question is not correct)
Please help me.
$ Cookie_file = dirname (_ FILE __). '/cookies/'.w.user.'cookie.txt'; // initialize $ curl = curl_init ('HTTP: // '); $ header = array (); $ 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 ); // do not output the header information curl_setopt ($ curl, CURLOPT_HEADER, 0); // save it to a string instead of curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ curl, CURLOPT_COOKIEJAR, $ cookie_file); // store cookies // post Data curl_setopt ($ curl, CURLOPT_POST, 1); // request data curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ post ); // whether to capture the redirected page curl_setopt ($ curl, CURLOPT_FOLLOWLOCATION, 1); $ response = curl_exec ($ curl); curl_close ($ curl );
Get session
It is not generic. Don't say no
// Obtain the cookie value private function getCookies () {$ curl = curl_init ('HTTP: // 113.57.132.2: 83/login. aspx '); // do not output the header information curl_setopt ($ curl, CURLOPT_HEADER, 1); curl_setopt ($ curl, CURLOPT_NOBODY, 1); // disguise the browser curl_setopt ($ curl, CURLOPT_USERAGENT, 'mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/123 '); // save it to a string instead of outputting curl_setopt ($ curl, CURLOPT_RETURNTRANS FER, 1); $ rs = curl_exec ($ curl); curl_close ($ curl); preg_match ('% ASP. NET_SessionId = .*?; % Sim ', $ rs, $ arr); $ cookies = str_replace ('asp. NET_SessionId = ', '', $ arr [0]); $ cookies = rtrim ($ cookies,'; '); return $ cookies; // $ this-> $ cookies = rtrim ($ cookies ,';');}