我酷下载
您的位置:首页-> 技术文章-> -> Delphi-> 如何获取TWebBrowser控件的超级链接

阅读排行




如何获取TWebBrowser控件的超级链接

作者未知 来源csdn 加入时间:2005-10-26 人气:214
procedure getAllLinks2(WB: TWebBrowser; var InnerText,Links: TStringList);
//needs unit as :shDocVw,Classes,MSHTML,variants
var
Htmldoc     : IHtmlDocument2;
AllLinks    : IhtmlElementCollection;
Len,I   : Integer;
//HtmlItem2    : Olevariant;
HtmlItem: IHTMLElement;
begin
HtmlDoc := WB.document as Ihtmldocument2;
// AllLinks := HtmlDoc.get_links;
AllLinks := HtmlDoc.links;
Len := AllLinks.length ;
Links.BeginUpdate;
Innertext.BeginUpdate;
For I :=0 To Len-1 do
begin
//HtmlItem2 := AllLinks.item(I,emptyparam);
HtmlItem := AllLinks.item(I,emptyparam) as IHTMLElement;
//StringList.Add(Htmlitem2.href);    //this is also a way to get the link


{if trim(HtmlItem.innerHTML)<>'' then
begin
Links.Add(trim(HtmlItem.ToString));
InnerText.Add(trim(HtmlItem.innerHTML));
end;
}

if trim(HtmlItem.innerText)<>'' then
begin
Links.Add(trim(HtmlItem.ToString));
InnerText.Add(trim(HtmlItem.Innertext));
end;

end;
Links.EndUpdate;
InnerText.EndUpdate;
end;


相关文章

相关软件

联系我们 广告服务 友情链接 版权说明 软件发布 下载帮助

CopyRight
2005-2016 www.5qcn.net All Rights Reserved 版权所有 【我酷】下载