用C++做一个登陆系统!

20 篇文章 0 订阅

http://zhidao.baidu.com/question/359106654.html

#include  <stdio.h> 
  #include  <string.h> 
  #include  <curl/curl.h> 
  #include  <curl/types.h> 
  #include  <curl/easy.h> 
   
   int  main( int  argc,  char   * argv[])
     {
  CURL  * curl;
 CURLcode res;
   
  struct  curl_slist  * headerlist = NULL;
   static   const   char  buf[]  =   " Expect: " ;
   
  curl_global_init(CURL_GLOBAL_ALL);
  curl  =  curl_easy_init();
  headerlist  =  curl_slist_append(headerlist, buf);
   
   if (curl) 
    {
      curl_easy_setopt(curl, CURLOPT_URL,  " https://passport.baidu.com/?login " );
      curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
      curl_easy_setopt(curl, CURLOPT_COOKIEJAR, " cookie_open.txt " ); // 把服务器发过来的cookie保存到cookie_open.txt 
   
  #ifdef SKIP_PEER_VERIFICATION
      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER,  0L );
   #endif 
   
  #ifdef SKIP_HOSTNAME_VERFICATION
      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST,  0L );
   #endif 
     res  =  curl_easy_perform(curl);
   
        /**/ /*  always cleanup  */ 
      curl_easy_cleanup(curl);
   
        /**/ /*  free slist  */ 
      curl_slist_free_all(headerlist);
  } 
   return   0 ;
  } 
   
   /**/ /* *******************login_hi_baidu**************** */ 
  #include  < stdio.h > 
  #include  < string .h > 
  #include  < curl / curl.h > 
  #include  < curl / types.h > 
  #include  < curl / easy.h > 
   
   int  main( int  argc,  char   * argv[])
     {
  CURL  * curl;
  CURLcode res;
  
   struct  curl_slist  * headerlist = NULL;
   static   const   char  buf[]  =   " Expect: " ;
   
  curl_global_init(CURL_GLOBAL_ALL);
  curl  =  curl_easy_init();
  headerlist  =  curl_slist_append(headerlist, buf);
   
   if (curl) 
     {
      curl_easy_setopt(curl, CURLOPT_URL,  " https://passport.baidu.com/?login " );
      curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
   
      curl_easy_setopt(curl,CURLOPT_POSTFIELDS, " username=ea99&password=&psp_tt=0&safeflg=0&return_method=get&u=http://hi.baidu.com/s%5Fyqguo " ); // 设置帐号密码,其余的信息是页面要求的,抓包即可看见。 
   
      curl_easy_setopt(curl,CURLOPT_COOKIEFILE, " cookie_open.txt " ); // 提交第一步保存的cookie 
       curl_easy_setopt(curl,CURLOPT_COOKIEJAR, " cookie_login.txt " ); // 保存登陆后的cookie 
   #ifdef SKIP_PEER_VERIFICATION
      curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER,  0L );
   #endif 
   
  #ifdef SKIP_HOSTNAME_VERFICATION
     curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST,  0L );
   #endif 
   
     res  =  curl_easy_perform(curl);
       /**/ /*  always cleanup  */ 
      curl_easy_cleanup(curl);
        /**/ /*  free slist  */ 
      curl_slist_free_all(headerlist);
  } 
   return   0 ;
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值