网页内容的猎取

	UpdateData(true);  //从控件到成员变量
	CInternetSession session;
	m_html = _T("");
	CHttpFile *file = NULL; 
	try
	{ 
		file	=	(CHttpFile*)session.OpenURL(m_url);
	} 
	catch(CInternetException*	m_pException)
	{ 
		file = NULL;
		m_pException->m_dwError;
		m_pException->Delete();
		session.Close(); 
		AfxMessageBox(_T("CInternetException"));
	} 
	CString strLine; 
	char	sRecived[1024];
	if(file != NULL) 
	{
		while(file->ReadString((LPTSTR)sRecived,1024)!=NULL) 
		{
				m_html += sRecived; 
		} 
	}
	else
	{
		AfxMessageBox(_T("fail")); 
	} 
	session.Close();
	file->Close();
	delete file; 
	file = NULL;
	UpdateData(false);

转载于:https://www.cnblogs.com/rogee/archive/2011/04/14/2015863.html

你可能感兴趣的:(网页内容的猎取)