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 );