PHP Simulation of the implementation of landing methods, here are listed two methods to achieve the simulation landing Renren. The specific example code is as follows:
(1) using Snoopy analog landing
<?php
set_time_limit (0);
Require "Snoopy.class.php";
$snoopy =new Snoopy ();
$snoopy->referer= ' http://www.renren.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.renren.com/PLogin.do ';//Login data submitted URL address
$snoopy->submit ($url, $submit _vars);
$snoopy->fetch ("http://www.renren.com/");/the page data you want to get
echo $snoopy->results;//www.alixixi.com
(2) using Curl Analog landing
<?php
set_time_limit (0);
$cookie _file=tempnam ('. tmp ', ' Cookie ');//tmp directory needs to establish a good
$ch =curl_init ();
$login _url= ' http://www.renren.com/PLogin.do ';
$curlPost = "email= login account &password= login password";
curl_setopt ($ch, Curlopt_url, $login _url);
When enabled, the header file's information is exported 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 way to send the request, post or get,curlopt_post or Curlopt_get
curl_setopt ($ch, Curlopt_postfields, $curlPost);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file); Save Cookie
curl_exec ($ch);
Curl_close ($ch);
$ch =curl_init ();
$login _url2= "http://www.renren.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 Cookie
curl_exec ($ch);
Curl_close ($ch);
Articles that you may be interested in
- Summary of the method of PHP simulating POST request
- phpMyAdmin How to set up automatic login
- How to simulate a ping command in PHP
- Summary of common system variables in thinkphp templates
- PHP simulates sending GET requests
- PHP simulates sending get and post requests, respectively
- PHP asynchronous execution method, analog multithreading
- How to set up phpMyAdmin automatic login and cancel automatic logon