The realization method of PHP simulation landing

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.