unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls,MSHTML;
type
TForm1 = class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetUrl: string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.GetUrl: string;
var
Document: IHtmlDocument2;
Link: IHTMLElement; StrLinks: string;
i: integer;
begin
Document := WebBrowser1.Document as IHtmlDocument2;
for i := 0 to Document.Links.Length - 1 do
begin
Link := Document.Links.Item(i, 0) as IHTMLElement;
memo1.Lines.Add (Link.toString);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetUrl;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
memo1.Text := IHtmlDocument2(WebBrowser1.Document).Body.OuterText
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
memo1.Text := IHtmlDocument2(WebBrowser1.Document).Body.outerHTML
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('http://delphi.ktop.com.tw/board.php?cid=30&fid=66&tid=66942');
end;
end.