[CPP]View Plaincopy
- Analogue Landing 115 Network disk
- #include <afxinet.h>//include related header files
- /* Grab the bag with the grab kit to get the data you need to submit, then simulate the commit.
- * (sometimes you need to get cookie information, you can use the Cinternetsession::getcookie () function to get the cookie information) */
[CPP]View Plaincopy
- 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)
- {
- //Here is the request header information, which is obtained by the Grab kit tool
- 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"));
- Here is the data to be submitted. Note: [e-mail protected] refers to the address of the login mailbox, the following xxxxxxx is the login password, when used for your own can
- TCHAR Szrequest[max_count] = _t ("Login%5baccount%[email protected]&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 ();
- }
http://blog.csdn.net/qing666888/article/details/43379349
Analog Login 115 Network Disk (MFC version)