模拟登陆115网盘(MFC版)

// 模拟登陆115网盘
#include <afxinet.h> // 包含相关的头文件


/* 用抓包工具抓包可得到需要提交的数据,然后模拟提交即可。
*(有的时候需要得到cookie信息,你可以使用CInternetSession::GetCookie()函数得到该cookie信息)*/

try
 {
#define MAX_COUNT 1024
  CInternetSession session(_T("session"));
  INTERNET_PORT nPort = 80;
  CHttpConnection* pHttpConnect = session.GetHttpConnection(_T("passport.115.com"), nPort);
  if(pHttpConnect)
  {
   CHttpFile* pFile = pHttpConnect->OpenRequest(CHttpConnection::HTTP_VERB_POST, _T("/?ac=login"));
   if(pFile)
   {
    // 这里是请求头信息,由抓包工具得到该信息
    pFile->AddRequestHeaders(_T("POST /?ac=login HTTP/1.1"));
    pFile->AddRequestHeaders(_T("Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"));
    pFile->AddRequestHeaders(_T("Referer: http://passport.115.com/?ac=login&goto=http%3A%2F%2Fu.115.com%2F%3Fac%3Dmy"));
    pFile->AddRequestHeaders(_T("Accept-Language: zh-cn"));
    pFile->AddRequestHeaders(_T("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; EasyBits GO v1.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"));
    pFile->AddRequestHeaders(_T("Content-Type: application/x-www-form-urlencoded"));
    pFile->AddRequestHeaders(_T("Accept-Encoding: gzip, deflate"));
    pFile->AddRequestHeaders(_T("Host: passport.115.com"));
    pFile->AddRequestHeaders(_T("Connection: Keep-Alive"));
    pFile->AddRequestHeaders(_T("Cache-Control: no-cache"));    
// 这里是要提交的数据。说明一下: xxxx@xx.xxx指的是登陆的邮箱的地址,后面的XXXXXXX表示的是登陆的密码,使用的时候换成你自己的即可
    TCHAR szRequest[MAX_COUNT] = _T("login%5Baccount%5D=xxxx@xx.xxx&login%5Bpasswd%5D=XXXXXXX&goto=http%3A%2F%2Fu.115.com%2F%3Fac%3Dmy");
    pFile->SendRequest(NULL, 0, szRequest, _tcslen(szRequest)+1);
    
    CString strStatus(_T(""));
    if(pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strStatus))
    {
     AfxMessageBox(strStatus);
    }
    pFile->Close();
    delete pFile;
    pFile = NULL;
   }
  }
  pHttpConnect->Close();
  delete pHttpConnect;
  pHttpConnect =NULL;  session.Close();
 }
 catch (CInternetException* e)
 {
  e->ReportError();
  e->Delete();
 }


 

评论 26
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值