PHP Simulation Landing Implementation Method analysis, PHP simulation landing implementation
This paper analyzes the implementation method of PHP simulation landing. Share to everyone for your reference. The specific analysis is as follows:
PHP simulation Landing Implementation method, here are listed two ways to achieve the simulation landing Renren. The specific instance code is as follows:
1) Log in using Snoopy:
Copy CodeThe code is as follows: <?php
Set_time_limit (0);
Require "Snoopy.class.php";
$snoopy =new Snoopy ();
$snoopy->referer= ' http://www.bkjia.com/';
$snoopy->agent= "mozilla/5.0 (Windows NT 6.1; rv:22.0) gecko/20100101 firefox/22.0";
$submit _vars[' email '] = ' login account ';
$submit _vars[' password '] = ' login password ';
$url = ' http://www.bkjia.com/test/Login.php ';//URL address of the login data submission
$snoopy->submit ($url, $submit _vars);
$snoopy->fetch ("http://www.bkjia.com/");//The page data you want to get
Echo $snoopy->results;//m.jb51.net
2) Use Curl to simulate login:
Copy CodeThe code is as follows: <?php
Set_time_limit (0);
$cookie _file=tempnam ('./tmp ', ' Cookie ');//tmp directory needs to be established first.
$ch =curl_init ();
$login _url= ' http://www.bkjia.com/PLogin.do ';
$curlPost = "email= login account &password= login password";
curl_setopt ($ch, Curlopt_url, $login _url);
When enabled, the header file information is output as a data stream
curl_setopt ($ch, curlopt_header,0); Set whether to output page content
curl_setopt ($ch, curlopt_returntransfer,1);
curl_setopt ($ch, curlopt_post,1); Set the request send mode, post or Get,curlopt_post or Curlopt_get
curl_setopt ($ch, Curlopt_postfields, $curlPost);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file); Save cookies
Curl_exec ($ch);
Curl_close ($ch);
$ch =curl_init ();
$login _url2= "http://www.bkjia.com/";
curl_setopt ($ch, Curlopt_url, $login _url2);
curl_setopt ($ch, curlopt_header,0);
curl_setopt ($ch, curlopt_returntransfer,0);
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file); Read cookies
Curl_exec ($ch);
Curl_close ($ch);
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/940488.html www.bkjia.com true http://www.bkjia.com/PHPjc/940488.html techarticle PHP Simulation Landing Implementation Method analysis, PHP simulation Landing implementation of this article analysis of the implementation of PHP simulation landing method. Share to everyone for your reference. The specific analysis is as follows: PHP Simulator login ...