CInternetSession session;
CHttpFile *file = NULL;
CString strURL ="www.baidu.com";
CString strHtml = ""; //存放网页数据
try
{
file = (CHttpFile*)session.OpenURL(strURL);
}
catch(CInternetException * m_pException)
{
file = NULL;
m_pException->m_dwError;
m_pException->Delete();
session.Close();
MessageBox("CInternetException");
}
CString strLine;
if(file != NULL)
{
while(file->ReadString(strLine) != NULL)
{
strHtml += strLine;
strHtml +="/r/n";
}
MessageBox(strHtml);
}
else
{
MessageBox("fail");
}
session.Close();
file->Close();
delete file;
file = NULL;
vc++ 读取网页源代码
最新推荐文章于 2017-07-22 12:21:01 发布