Uses MSHTML;
procedure TForm1.Button1Click(Sender: TObject);
var
doc: IHTMLDocument2;
all: IHTMLElementCollection;
len,i: integer;
item: OleVariant;
begin
doc := WebBrowser1.Document as IHTMLDocument2;
all := doc.Get_links;
len := all.length;
for i := 0 to len - 1 do begin
item := all.item(i,varempty);
//获得链接的标题文本与链接地址
Memo1.Lines.Add(item.innertext + '[' + item.href + ']');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.google.com');
end;