DelphiTwebbrowser 如何提取含有 iframe 网页 (HTML) 的表
格 (table) 数据
DelphiTwebbrowser 如何提取含有 iframe 网页 (HTML)
的表格 (table) 数据 -- (转载) 如何提取含有 iframe 网页
(HTML) 的表格 (table) 数据 想提取网页里的表格 (table 标
签)数据 , 因为 session 的原来 ,所以用了 ,但些网页被包含在一
个 iframe 里 ,所以在论坛上找到了一高人的代码 (参考代码
一),用 FrameWin.document.body.outerHTML 得到了源码 ,
但问题是 ,我想得到 table 表里的数据 ,好像没有
FrameWin.document.all.tags('table').item(0).outerHTML 这
种形式 ,但 WebBrowser 却有 .如参考代码二 ,因为要提取的网
页的表格是通过另一同级 iframe 网页的 javascript 赋值的,
所以不能直接通过 FrameWin.document.body.outerHTML
用字符串直接分析,那样得的数据都是空格。
大家有什么好办法。 。
参考代码一 :
usr mshtml;
procedure TMainForm.ToolButton56Click(Sender:
TObject);
var
Index: Integer;
Document: IHTMLDocument2;
FrameIdx: OleVariant;
FrameDis: IDispatch;
FrameWin: IHTMLWindow2;
begin
while Webbrowser1.ReadyState <>
READYSTATE_COMPLETE do
Application.ProcessMessages;
if WebBrowser1.Document = nil then
Exit;
if
WebBrowser1.Document.QueryInterface(IHTMLDocument
2, Document) <> 0 then Exit;
if Document.frames.length > 0 then
begin
for Index := 0 to
Document.frames.length - 1 do
begin
FrameIdx := Index;
FrameDis :=
Document.frames.item(FrameIdx);