To extract google Part of the search data , Find out google For the software to capture its data, the shielding is powerful , I used to fake it USER-AGENT  You can capture the data , But not now . Using packet capture data to discover ,Google  Determine the  cookies, When you don't cookies When , direct return  302  Jump , And it's dozens in a row 302 Jump , There's no data at all .

therefore , When sending a search command , It needs to be extracted first  cookies  And save , And then use the saved one cookies Send the search command again to capture the data normally . This is actually the same reason as the simulated Login of the forum , First POST Sign in , obtain cookies And save , And then use this cookies Just visit .

One 、 Definition Cookie Storage path

Absolute path must be used

$cookie_jar = dirname(__FILE__)."/pic.cookie";

Two 、 obtain Cookie

take cookie File in

$url = "http://1.2.3.4/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
$content = curl_exec($ch);
curl_close($ch);

3、 ... and 、 Simulate the browser to get the verification code

The server verification code is vulnerable , You can specify that

Take out cookie, Submit to the server together , Let the server think it's the browser opening the landing page

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://1.2.3.4/getCheckpic.action?rand=6836.185874812305');
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);

Four 、POST Submit

$post = "name=2&userType=1&passwd=asdf&loginType=1&rand=6836&imageField.x=25&imageField.y=7";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://1.2.3.4/loginstudent.action");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
$result=curl_exec($ch);
curl_close($ch);

5、 ... and 、 Get the data from the specified page

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://1.2.3.4/accountcardUser.action");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
$html=curl_exec($ch);
// var_dump($html);
curl_close($ch);

Original address :http://www.php100.com/html/php/lei/2013/0912/6164.html

PHP obtain Cookie Simulated Login CURL More articles about

  1. PHP obtain Cookie Simulated Login CURL( turn )

    To extract google Part of the search data , Find out google For the software to capture its data, the shielding is powerful , I used to fake it USER-AGENT  You can capture the data , But not now . Using packet capture data to discover ,Google  Determine the  cookie ...

  2. Java adopt httpclient obtain cookie Simulated Login

    package Step1; import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.Htt ...

  3. PHP obtain Cookie Simulated Login

    keyword :CURL Cookie CURLOPT_COOKIEJAR CURLOPT_COOKIEFILE  Simulated Login PHP author : Original of fangbei studio :http://www.cnblogs.com/txw19 ...

  4. PHP cURL Use cookie Simulated Login

    cURL What is it? cURL: http://php.net/manual/zh/book.curl.php PHP Support Daniel Stenberg Created libcurl library , Be able to connect all kinds of communication services ...

  5. Python3 Utilization of Cookie Simulated Login

    Python3 Utilization of Cookie Simulated Login utilize Cookie Simulate login steps : 1.       Type in the browser http://demo.bxcker.com, Enter your user name and password to log in . 2. Login success point " ...

  6. Python Manual construction Cookie Get the content of website page after simulated Login

    Recently, a friend asked me to help me crawl a novel , The first 30 chapters of the novel are directly readable , The following chapters need to be recharged VIP so . So we need to use VIP After account login , structure Cookie, Reuse Python For each chapter url, Get the content and use it PyQ ...

  7. Verification code processing +cookie Simulated Login

    One . background Related blogs :https://www.jianshu.com/p/9fce799edf1e https://blog.csdn.net/h19910518/article/details/793 ...

  8. Huang Cong :C# belt cookie Simulated Login Baidu

    #region Synchronized through POST Send data by /// <summary> /// adopt POST Send data by /// </summary> /// <param name= ...

  9. C# belt cookie Simulated Login Baidu

    #region Synchronized through POST Send data by /// <summary> /// adopt POST Send data by /// </summary> /// <param name= ...

Random recommendation

  1. AI in the game —— On AI

    One . AI in the game Make the game challenging : The key to making the game fun is to find the right difficulty level for it : The role of AI in the game is to make the game more interesting by providing challenging competitors , And the non player characters who act realistically in the game (NPC), ...

  2. windows cmd command line command

    Reference: 1. http://msdn.microsoft.com/en-us/library/ms977170.aspx( There's a paragraph ahead VB It doesn't matter if you don't understand ) 2. http://csserve ...

  3. Java Summary of methods of generating random characters in

    package learnExercise; public class RandomCharacter { public static char getRandomCharacter(char ch1 ...

  4. JS in NULL and undifined Differences and NULL The role of

    1. Blog address :http://www.cnblogs.com/eastday/archive/2010/03/03/1677324.html 2. Reference address 2:https://www.zhihu.com/ ...

  5. FPGA design idea ( Continuous updating )

    One . pipeline Design The larger combinational logic completed by one clock cycle is divided into several clock cycles after reasonable cutting . The clock frequency of the logic operation of this part will be significantly increased , Improve the performance of the system with area for speed A pipeline design needs 4 One step, one number ...

  6. How to use phpstudy Build multi site environment

    http://jingyan.baidu.com/article/e52e36154227ef40c70c5147.html Usually when developing a project , When multiple projects are developed at the same time, they have to be placed in the root directory to work properly ...

  7. h5 The web version of Weibo and wechat QQ Sign in

    One : Microblogging 1, Let's talk about Weibo first , First of all, you should go http://open.weibo.com/wiki/ Register account number first , Through verification audit . And then create a web application . The reason why microblog fails to pass the audit is the domain name and website address , Be sure to write according to the actual situation . must do ...

  8. mysql case when * else end

    Calculate the total number by conditions SELECT -- SUM( END) as am, -- SUM( END) as om , -- SUM( END) as aom , -- SUM( then AmoutPric ...

  9. Preliminary discussion wheel Group

    introduction In a process su There's a question when I ask you to switch , [cheng1@localhost ~]$ su cheng2 password : su: Identify faults [cheng1@localhost ~]$ Tried many times , also ...

  10. [luogu3388][ Cut point ]

    Topic link Ideas Real board questions . A cut point is in an undirected graph , Delete the points that will no longer be connected . It can be used tarjan Algorithm for . According to the cut point, there are two cases , One is root , One is the root of right and wrong . If it's not root, judge it tarjan What the current node can reach at the time of ...