using namespace System;
using namespace System::Net;
void Login()
{
ManagedObject<HttpRequest> request = WebClient::GetHttpRequest(_T("http://blog.com/wp-login.php"));
if (request.IsSatisfied())
{
//我们只需要得到Cookie无须跟随重定向
request->AutoRedirect = false;
HttpResponse *response = nullptr;
WebClient::PostResponseStream(Nothing,
_T("log=565998735@qq.com&pwd=123456&wp-submit=Log+in"),
request, &response);
if (response){
GlobalizeString cookie(Response->GetResponseHeader("Set-Cookie"));
Response->Close();
//利用得到的Cookie尝试获取登录后的网页
request = WebClient::GetHttpRequest(_T("http://RLib.blog.com/wp-admin/?c=1"));
request->AutoRedirect = false;
request->Headers.Add("Cookie", cookie.toGBK());
String Page = WebClient::GetResponseText(Nothing, request);
} //if
} //if
}
C++调用WebClient模拟登录Blog.com代码
最新推荐文章于 2022-10-14 11:04:55 发布