Phpcurl simulates logon to Baidu homepage

Source: Internet
Author: User
Phpcurl simulates logon to the Baidu homepage. the Last Post is edited by STONEWP from 2012-03-2913: 43: 04 as follows: & lt ;? Php $ url & nbsp; passport.baidu.com? Login & amp; tplmn; $ url & nbsp; www php curl simulate logon to Baidu homepage

This post was last edited by STONEWP on 13:43:04

The code is as follows:
 $ Url = "https://passport.baidu.com /? Login & tpl = mn ";
// $ Url = "http://www.baidu.com /";
$ Cookdir = "d:/www/html/mndl/cookie.txt ";
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE); // This statement must be set to not verify the certificate. the host is not verified.
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookdir); // save cookies and send the user's browser information to the access source
Curl_setopt ($ ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;. net clr 1.1.4322;. net clr 2.0.50727 )");
Curl_setopt ($ ch, CURLOPT_REFERER, "http://www.baidu.com /");
$ Contents = curl_exec ($ ch );
Curl_close ($ ch );

/* Original Form style
















*/
$ Post_fields = array ();
$ Post_fields = preg_data ($ contents, 'id', $ post_fields );
$ Post_fields = preg_data ($ contents, 'isphone', $ post_fields );
$ Post_fields ['mem _ pass'] = 'on'; // The post data array remembers my logon status
$ Post_fields = preg_data ($ contents, 'more _ param', $ post_fields );
$ Post_fields = preg_data ($ contents, 'need _ coin ', $ post_fields );
$ Post_fields = preg_data ($ contents, 'need _ pay', $ post_fields );
$ Post_fields = preg_data ($ contents, 'next _ target', $ post_fields );
$ Post_fields ['password'] = 'password'; // The post data array remembers my logon status
$ Post_fields = preg_data ($ contents, 'pay _ method', $ post_fields );
$ Post_fields = preg_data ($ contents, 'PSP _ TT', $ post_fields );
$ Post_fields = preg_data ($ contents, 'Return _ method', $ post_fields );
$ Post_fields = preg_data ($ contents, 'Return _ type', $ post_fields );
$ Post_fields = preg_data2 ($ contents, 'safeflg', $ post_fields );
$ Post_fields = preg_data ($ contents, 'skip _ OK ', $ post_fields );
$ Post_fields = preg_data ($ contents, 'tpl', $ post_fields );
$ Post_fields = preg_data ($ contents, 'tpl _ OK ', $ post_fields );
$ Post_fields ['u'] = 'http: // www.baidu.com /';
$ Post_fields ['username'] = 'username'; // The post data array remembers my logon status
$ Post_fields ['verifycode'] = '';

$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );

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.