64,684
社区成员
发帖
与我相关
我的任务
分享
CString httpGet(CString url) {
USES_CONVERSION;
CInternetSession s;
CHttpFile *fileGet;
try{
fileGet = (CHttpFile*)s.OpenURL(url);
DWORD status;
fileGet->QueryInfoStatusCode(status);
// cout << status;
} catch (CInternetException *ex) {
fileGet = NULL;
ex->m_dwError;
ex->Delete();
s.Close();
cout << "http请求异常";
return L"";
}
CString strHtml = _T("");
char sRecived[1024];
while (fileGet->ReadString((LPTSTR)sRecived, 1024) != NULL) {
strHtml += sRecived;
}
return strHtml;
char *pChar = W2A(strHtml.GetBuffer());
CString gb2312String = ConvertUTF8toGB2312(pChar, strlen(pChar));
fileGet->Close();
delete fileGet;
s.Close();
return gb2312String;
}
CString response = httpGet(L"http://www.163.com/");
string text = cstr2str(response);
cout << text;
const regex reg(".*"); //这里怎么写都不起作用
cout << regex_match(text, reg);
while (true);
return 0;