procedure TForm27.Button1Click(Sender: TObject);
var
doc2: IHTMLDocument2;
doc3: IHTMLDocument3;
itableCollection, emtCollection: IHTMLElementCollection;
itable: IHTMLTABLE;
emt: IHTMLElement;
tabrow: IHTMLTableRow;
tabsec: IHTMLTableSection;
I, J, K: integer;
sid, s1, s2, s3, s4, s5, sText: string;
begin
ListBox1.Clear;
WebBrowser1.Navigate('http://zx.caipiao.163.com/trend/11xuan5/?beginPeriod=14092901&endPeriod=14100875&selectDate=4');
while WebBrowser1.Busy do
Application.ProcessMessages;
doc2 := self.WebBrowser1.Document as IHTMLDocument2;
doc3 := WebBrowser1.Document as IHTMLDocument3;
itableCollection := doc2.all.tags('table') as IHTMLElementCollection;
for I := to itableCollection.Length - do
begin
itable := itableCollection.item(I, ) as IHTMLTABLE;
emt := itable as IHTMLElement;
if emt.id = 'chartsTable' then
begin
emt := itable.tBodies.item(, ) as IHTMLElement; // tbody cpdata
tabsec := emt as IHTMLTableSection;
tabsec.rows.Length;
for J := to tabsec.rows.Length - do
begin
tabrow := tabsec.rows.item(J, ) as IHTMLTableRow;
if tabrow.cells.Length < then
Continue;
sid := (tabrow.cells.item(, ) as IHTMLElement).innerText; //
s1 := (tabrow.cells.item(, ) as IHTMLElement).innerText; //
s2 := (tabrow.cells.item(, ) as IHTMLElement).innerText; //
s3 := (tabrow.cells.item(, ) as IHTMLElement).innerText; //
s4 := (tabrow.cells.item(, ) as IHTMLElement).innerText; //
s5 := (tabrow.cells.item(, ) as IHTMLElement).innerText; //
sText := Format('%s %s %s %s %s %s', [sid, s1, s2, s3, s4, s5]);
ListBox1.Items.Add(sText);
end;
end;
end;
end;