呵呵~看到你的问题,有点意思就写这东东给你吧unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, MSHTML, OleCtrls, SHDocVw, StrUtils, ExtCtrls;type TForm1 = class(TForm) ListView1: TListView;
Button1: TButton;
Memo1: TMemo;
WebBrowser1: TWebBrowser;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private { Private declarations } procedure MemoToLV(Memo: TMemo;
ListView: TListView);
public { Public declarations } end;
var Form1: TForm1;
LV_s: array [1..8] of string;implementation{$R *.dfm}procedure TForm1.MemoToLV(Memo: TMemo;
ListView: TListView);var s: string;
i,k: integer;
begin
ListView.Items.Clear;
k := 1;
for i:= 0 to Memo.Lines.Count-1do
begin
s := Trim(Memo.Lines.Strings);
if s='<TR>' then
begin
with ListView.Items.Adddo
begin
Caption := LV_s[1];
SubItems.Append(LV_s[2]);
SubItems.Append(LV_s[3]);
SubItems.Append(LV_s[4]);
SubItems.Append(LV_s[5]);
SubItems.Append(LV_s[6]);
SubItems.Append(LV_s[7]);
SubItems.Append(LV_s[8]);
end;
k := 1;
end else
begin
LV_s[k] := s;
inc(k);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.boc.cn/sourcedb/whpj/');
Timer1.Enabled := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);var k,k1: integer;
s: string;
begin
try Memo1.Clear;
s := IHtmlDocument2(WebBrowser1.Document).Body.outerHTML;
k := pos('<TD class=nav bgColor=#ffffff vAlign=center width=86 align=middle>',s);
k1 := pos('</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>',s);
s := copy(s,k,k1-k);
s := AnsiReplaceText(s, '<TD class=nav bgColor=#ffffff vAlign=center width=86 align=middle>', '');
s := AnsiReplaceText(s, '</TD>', '');
s := AnsiReplaceText(s, '</TR>', '')+#13#10+'<TR>';
Memo1.Lines.Append(s);
MemoToLV(Memo1,ListView1);
Timer1.Enabled := False;
except end;
end;
end.