#include <afxinet.h>
void CReadInternetDataDlg::OnRead()
{
CInternetSession c ;
CHttpFile * p=NULL ;
p=(CHttpFile*)c.OpenURL("http://127.0.0.1/web") ; //打开一个URL
CString str ;
CString info="";
while(p->ReadString(str)) //读取网页数据
info+=str ;
(this->GetDlgItem(IDC_EDIT1))->SetWindowText(info);
}
使用C++读取HTTP网页数据
本文介绍了一个简单的C++程序,该程序利用MFC库中的CInternetSession和CHttpFile类从指定URL(例如'http://127.0.0.1/web')读取网页数据,并将读取到的内容显示在一个对话框的编辑框中。
523

被折叠的 条评论
为什么被折叠?



