1、 TButton;WebBrowser1: TWebBrowser;procedure FormCreate(Sender: TObject);procedure Button1Click(Sender:private Private declarations public Public declarations end;varForm1: TForm1;implementation$R *.dfmfunctionGetHtmlTableCell(aTable: IHTMLTable; aRow, aCol:Integer): IHTMLElement;Row: IHTMLTableRow;b
2、eginResult := nil;if aTable = nil then Exit;if aTable.rows = nil then Exit;Row := aTable.rows.item(aRow, aRow) asIHTMLTableRow;if Row = nil then Exit;= Row.cells.item(aCol, aCol) as IHTMLElement;function GetHtmlTable(aDoc: IHTMLDocument2;aIndex: Integer):list: IHTMLElementCollection;if aDoc = nil th
3、en Exit;if aDoc.all = nil then Exit;list := aDoc.all.tags(table) as IHTMLElementCollection;if list = nil then Exit;= list.item(aIndex, aIndex) as IHTMLTable;function GetWebBrowserHtmlTableCellText(constAWebBrowser:const TableIndex, RowIndex, ColIndex: Integer;var ResValue: string): Boolean;Docintf:t
4、blintf:node:ResValue := docintf := AWebBrowser.Document asIHTMLDocument2;tblintf := GetHtmlTable(docintf, TableIndex);node := GetHtmlTableCell(tblintf, RowIndex, ColIndex);= node <> nil;if Result then= Trim(node.innerText);function GetHtmlTableRowHtml(aTable:aRow:= Row as IHTMLElement;function
5、 GetWebBrowserHtmlTableCellHtml(const;= Trim(node.innerHTML);function GeHtmlTableHtml(aTable:function GetWebBrowserHtmlTableHtml(constconst TableIndex, RowIndex:= GeHtmlTableHtml(tblintf, RowIndex);= node.innerHtml;procedure TForm1.FormCreate(Sender:WebBrowser1.Navigate(H:ReadTable00.html);procedure TForm1.Button1Click(Sender:ResValue: string;if GetWebBrowserHtmlTableCellText(WebBrowser1, 0, 0, 0, ResValue) thenShowMessage(ResValue);end elseShowMessage( 指定的表格不存在 end.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1