DELPHI自动分析表单(WebBrowser)

//-----先创建一个WebBrowser,以及自己Negative,也就是先打开一个页面
///----------------stringgrid初始化-------------
procedure TForm1.stringCreate(StringGrid: TStringGrid);
begin
StringGrid.Cells[0, 0] := '序号 ';
StringGrid.Cells[1, 0] := 'ID号 ';
StringGrid.Cells[2, 0] := '类别 ';
StringGrid.Cells[3, 0] := '类型 ';
StringGrid.Cells[4, 0] := '名称 ';
StringGrid.Cells[5, 0] := '数值 ';
end;

----------------取得一个页面的可能的按键信息0------------------
function TForm1.GetAll(web: TWebBrowser): Boolean;
var
n, m: Integer;
Myweb: OleVariant;
begin
Myweb := web.Document;
m := 1;
for n := 0 to Myweb.all.length -1 do // A编历所有的元素
begin
try
if Myweb.All.item(n).type = 'hidden' then //跳过隐藏不可用的类型
Continue;
except
continue;
end;
StringGrid1.Cells[0, n] := IntToStr(m);
StringGrid1.Cells[1, n] := IntToStr(n);
StringGrid1.Cells[2, n] := Myweb.All.item(n).tagname;
StringGrid1.Cells[3, n] := Myweb.All.item(n).type;
try
StringGrid1.Cells[4, n] := Myweb.All.item(n).Name;
StringGrid1.Cells[5, n] := Myweb.alL.item(n).value;
except

end;
StringGrid1.RowCount := StringGrid1.RowCount + 1; //对stringGrid添加新的一行
m := m + 1;
end;
end;

posted on 2012-02-22 11:03  long6  阅读(1466)  评论(0编辑  收藏  举报

导航