📄 提取网页form中所有控件的名字和值.txt
字号:
提取网页Form中所有控件的名字和值(Name & Value)
procedure THtmlTestFrm.GetInputNameList(AList: TStrings);
var
HTMLDocument:IHTMLDocument2;
All,AllForms:IHTMLElementCollection;
Index,Item:OleVariant;
i,Count:integer;
begin
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
All:=HTMLDocument.all;
AList.Clear;
Index:=0; //表示第一个Form
AllForms:=HTMLDocument.forms;
Item:=AllForms.item(varempty,Index);
Count:=Item.elements.Length;
for i:=0 to Count-1 do
begin
AList.Add(Item.elements.item(i).Name);
end;
end;
procedure THtmlTestFrm.GetInputValueList(AList: TStrings);
var
HTMLDocument:IHTMLDocument2;
All,AllForms:IHTMLElementCollection;
Index,Item:OleVariant;
i,Count:integer;
begin
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
All:=HTMLDocument.all;
AList.Clear;
Index:=0;
AllForms:=HTMLDocument.forms;
Item:=AllForms.item(varempty,Index);
Count:=Item.elements.Length;
for i:=0 to Count-1 do
begin
AList.Add(Item.elements.item(i).value);
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -