怎么用C++访问网页???
访问的是url,
如:“http://www.renren.com/profile.do?id=XXXXXX”,
并且后面的id是可以改动的。。。
[解决办法]
用sokcet+html打包封装也可实现与网页的交互,但如果要显示网页,老老实实用MFC等类库,标准C++无法简单实现
[解决办法]
看你是像达到什么效果,如果仅仅想通过网络,获取网页,有soeket实现HTTP协议就可以,如果你是想达到浏览器一样的效果,在MFC中就可很容易实现:
建一个单文档工程,class CTesthtmlView : public CHtmlView。注意view类一定要从CHtmlView继承。
创建完之后在void CTesthtmlView::OnInitialUpdate()函数中,默认代码如下:
void CTesthtmlView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();
// TODO: This code navigates to a popular spot on the web.
// change the code to go where you'd like.
Navigate2(_T("http://www.microsoft.com/visualc/"),NULL,NULL);
}
将http://www.microsoft.com/visualc/改为你要的网页URL,当然你自己可以修定,
如CString url;
int i=123;
url.Format("www.sohu.com/%d.html",i);
Navigate2(url,NULL,NULL);
这样就OK了
[解决办法]