PHP Curl Simulation Login Baidu Home Solution

Source: Internet
Author: User
PHP Curl Simulation Login Baidu homepage
The code is as follows:
PHP Code
  
                                                                                                                                                                                                                                                  */$post _fields = Array (), $post _fields = Preg_data ($contents, ' aid ', $post _fields); $post _fields = Preg_data ($contents, ' Isphone ', $post _fields); $post _fields[' mem_pass '] = ' on '; The post data array remembers my login 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 login 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 '; Post data array Remember my login status $post_fields[' verifycode ' = '; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ( $ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_post, 1); Curl_setopt ($ CH, curlopt_postfields, $post _fields); curl_setopt ($ch, Curlopt_cookiejar, $cookdir); 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, "Https://passport.baidu.com/?login &tpl=mn "), Curl_exec ($ch), Curl_close ($ch), $url =" http://www.baidu.com/"; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_cookiefile, $cookdir); 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/n"), $contents = Curl_exec ($ch);p rint_r ($contents);d ie;curl_close ($ch); exit function Preg_data ($source, $CHR, $array) {Preg_match ('/
  
   
     I/I ', $source, $matches);        if (!empty ($matches)) {$a = $matches [1];        } else {die (' not found the '. $chr. ');        } $array [$CHR]= $a; return $array;} function Preg_data2 ($source, $CHR, $array) {Preg_match ('/
    
      I/I ', $source, $matches);        if (!empty ($matches)) {$a = $matches [1];        } else {die (' not found the '. $chr. ');        } $array [$CHR]= $a; return $array;}?
 > 
     
  • 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.