求救,如何得到TWebBrowser中的页面的内容?

lazybull 2003-09-22 12:23:38
我内嵌了一个TWebBrowser,打开了一个页面后,我如果可能得到TWebBrowser里面页面的内容,可以是html语言的源文件,或者其他内容。
...全文
35 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kimhao 2003-10-14
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
doc:IHTMLDocument2;
begin
doc := WebBrowser1.Document as IHTMLDocument2;
memo1.text:=doc.body.innerHTML ;
NavigateFrameset(doc) ;
end;

procedure TForm1.NavigateFrameset(document: IHTMLDocument2);
var
index: Integer;
ole_index: OleVariant;
frame_dispatch: IDispatch;
framed: IHTMLWindow2;
begin
if document = nil then
exit;
try
Application.MessageBox(
PChar('Content:' + String(document.body.innerHTML)),
PChar('URL: ' + String(document.URL)),MB_OK or
MB_ICONINFORMATION);
for index := 1 to document.Frames.Length do
try
ole_index := index-1;
frame_dispatch := document.Frames.Item(ole_index);
if frame_dispatch <> nil then
begin
framed := frame_dispatch as IHTMLWindow2;
NavigateFrameset(framed.document);
end;
except
on E: Exception do
begin
end
end;
except
on E: Exception do
begin
Application.MessageBox(PChar(E.Message),
PChar('Exception'));
end;
end;
end;
import the "Microsoft HTML Object Library" (MSHTML.TLB) and include MSHTML_TLB in the unit's uses clause
这个问题困扰我很长时间,今天彻底解决了,希望和大家共享,绝对通过了,别怕麻烦,你拷贝过去,试验一下
可以显示所有frame
大聪 2003-09-22
  • 打赏
  • 举报
回复
没用过,

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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