下面是个超简单的如何获取TWebBrowser控件的超级链接教程,图老师小编精心挑选推荐,大家行行好,多给几个赞吧,小编吐血跪求~
【 tulaoshi.com - 编程语言 】
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;
来源:http://www.tulaoshi.com/n/20160219/1626407.html
看过《如何获取TWebBrowser控件的超级链接》的人还看了以下文章 更多>>