在delphi 使用webbrowser如何取得网页的文字内容?

jachael_lj 2014-11-18 09:13:56
在delphi 使用webbrowser如何取得网页的文字内容??

感谢回复:
...全文
2961 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mingle lu 2014-12-15
  • 打赏
  • 举报
回复
奇怪,不是webbrowser.OleObject.document.body.innerText吗?
lsj60915kgy 2014-11-30
  • 打赏
  • 举报
回复
在网上搜到了如下内容:能否把这个翻译成delphi,头大!!! /////////////////////////////////////////////////////////////// IHTMLDocument2* GetDocFromFrame(IHTMLDocument2* pDoc2) { CComPtr<IHTMLDocument3> pDoc3; CComPtr<IHTMLDocument2> pDoc2Frame; hr = pDoc2->QueryInterface(IID_IHTMLDocument3,(void**)&pDoc3) ; if(hr==S_OK) { CComBSTR bstrName("FRAME");//CComBSTR bstrName("IFRAME"); CComPtr<IHTMLElementCollection> pElemCollFrame; hr=pDoc3->getElementsByTagName(bstrName,&pElemCollFrame); if (hr!=S_OK) return NULL; long pLength; hr=pElemCollFrame->get_length(&pLength); if(hr!=S_OK) return NULL; for(int i=0;i<pLength;i++) { IDispatch *pDispFrame=NULL; CComVariant vIndex=i; hr=pElemCollFrame->item(vIndex,vIndex,&pDispFrame); if(hr!=S_OK) continue; CComPtr<IHTMLElement> pElemFrame; hr=pDispFrame->QueryInterface(IID_IHTMLElement,(void**)&pElemFrame); if(hr!=S_OK) continue; CComPtr<IHTMLFrameBase2> pFrameBase2; hr=pElemFrame->QueryInterface(IID_IHTMLFrameBase2,(void**)&pFrameBase2); if(hr!=S_OK) continue; CComPtr<IHTMLWindow2> pWindow2; hr=pFrameBase2->get_contentWindow(&pWindow2); if(hr==S_OK) { hr=pWindow2->get_document(&pDoc2Frame); if (hr==S_OK) { return pDoc2Frame; } } } pDispFrame->Release(); } return NULL; }
lsj60915kgy 2014-11-30
  • 打赏
  • 举报
回复
自己顶一下。难道在IE下面还有一个Frame,再下面才是Document ?
levonsoft 2014-11-19
  • 打赏
  • 举报
回复
why not use idhttp.get?
不得闲 2014-11-19
  • 打赏
  • 举报
回复
获得IHTMLDocument2接口,然后就能获得了
lsj60915kgy 2014-11-19
  • 打赏
  • 举报
回复
借问: //用delphi与网页交互时出现的问题,ie.document没有值。 //实现的功能是,自动点打印审批网页里的同意按钮。 var Wnd: HWND; WndChild:HWND; doc:IHtmlDocument2; IE: iwebbrowser2; All: IHtmlElementCollection; HtmlElement: IHtmlElement; len,i:integer; item:OleVariant; begin Wnd := FindWindow('IEFrame', '打印审批 - Windows Internet Explorer'); WndChild := FindWindowEx(Wnd, 0,'Frame Tab', nil); WndChild := FindWindowEx(WndChild, 0,'TabWindowClass', nil ); WndChild := FindWindowEX(WndChild, 0, 'Shell DocObject View', nil); WndChild := FindWindowEX(WndChild, 0, 'Internet Explorer_Server', nil);//找到'Internet Explorer_Server'类的句柄 if WndChild <> 0 then begin GetIEFromHWnd(WndChild, IE); if(IE <>nil) then begin doc:=IE.Document as IHtmlDocument2;//这里就出错了,doc得到的值是0,ie是有值的,不知何故。 //注:网页是完成打印审批功能的,是动态生成的网页,地址栏里有asp?,打开网页源代码一看,里面全部都是代码。而换了其它非动态的网页调试时是可以运行的。 all:=doc.links ; len:=all.length; //.......... ----------------------------------------------

1,594

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧