PHP Simulation Landing Implementation Method analysis, PHP simulation landing Implementation _php Tutorial

Source: Internet
Author: User

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 ...

  • Related Article

    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.