1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| procedure TForm1.Button3Click(Sender: TObject);
var
Document, Doc: IHTMLDocument2;
Body: IHTMLElement2;
Tags, Tags2, Coll: IHTMLElementCollection;
Anchor : IHTMLAnchorElement;
Tag, Elemt, event : IHTMLElement;
I, Inx, Inx2: Integer;
S : String;
begin
// Check for valid document: require IHTMLDocument2 interface to it
if not Supports(WebBrowser1.Document, IHTMLDocument2, Document) then
raise Exception.Create('Invalid HTML document');
// Check for valid body element: require IHTMLElement2 interface to it
if not Supports(Document.body, IHTMLElement2, Body) then
raise Exception.Create('Can''t find <body> element');
Tags := Body.getElementsByTagName('*');
inx := 0;
inx2 := 0;
StringGrid1.RowCount := 1;
StringGrid2.RowCount := 1;
for I := 0 to Pred(Tags.length) do
begin
Tag := Tags.item(I, EmptyParam) as IHTMLElement;
if (Tag.className = 'event__match event__match--live event__match--last highlighted event__match--inline event__match--oneLine') or
(Tag.className = 'event__match event__match--scheduled event__match--last event__match--inline event__match--oneLine') or
(Tag.className = 'event__match event__match--last event__match--inline event__match--oneLine') then
begin
Inc(Inx);
StringGrid1.RowCount := Inx+1;
StringGrid1.Cells[0,Inx] := IntToStr(Inx);
StringGrid1.Cells[1,Inx] := Tag.id;
StringGrid1.Cells[2,Inx] := Tag.innerText;
StringGrid1.Cells[3,Inx] := Tag.className;
Elemt := (WebBrowser1.Document as IHTMLDocument3).getElementById(Tag.id);
Inc(Inx2);
StringGrid2.RowCount := Inx2+1;
StringGrid2.Cells[0,Inx2] := IntToStr(Inx2);
StringGrid2.Cells[1,Inx2] := WebBrowser1.OleObject.Document.GetElementByID(Tag.id).Id;
StringGrid2.Cells[2,Inx2] := WebBrowser1.OleObject.Document.GetElementByID(Tag.id).getElementsByTagName('event_time');
end;
end;
end; |
Partager