procedure AutoLogin(iDoc1:IHTMLDocument2);
var
spDisp: IDispatch;
j: integer;
iELC : IHTMLElementCollection ;
S2,sn : string;
HtmlInputEle : IHTMLInputElement;
HTMLFormEle : IHTMLFormElement;
IF_Have:Boolean;
begin
if iDoc1 <> nil then
begin
ielc:=idoc1.Get_all;
for j:=0 to ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then
begin
HTMLFormEle :=HtmlInputEle.form;
IF_Have:=true;
with HtmlInputEle do
begin
S2:=Type_;
S2:=UpperCase(S2);
if StrComp(PChar(S2),'TEXT')=0 then
begin
sn := name;
sn := UpperCase(sn);
if StrComp(PChar(sn),'U')=0 then
value :='12313';
end;
if StrComp(PChar(S2),'PASSWORD')=0 then
begin
sn := name;
sn := UpperCase(sn);
if StrComp(PChar(sn),'PSW')=0 then
value :='1213';
end;
end;
end;
end; //END FOR
if(IF_Have)then
HTMLFormEle.submit;
end;
end;
var
spDisp: IDispatch;
j: integer;
iELC : IHTMLElementCollection ;
S2,sn : string;
HtmlInputEle : IHTMLInputElement;
HTMLFormEle : IHTMLFormElement;
IF_Have:Boolean;
begin
if iDoc1 <> nil then
begin
ielc:=idoc1.Get_all;
for j:=0 to ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then
begin
HTMLFormEle :=HtmlInputEle.form;
IF_Have:=true;
with HtmlInputEle do
begin
S2:=Type_;
S2:=UpperCase(S2);
if StrComp(PChar(S2),'TEXT')=0 then
begin
sn := name;
sn := UpperCase(sn);
if StrComp(PChar(sn),'U')=0 then
value :='12313';
end;
if StrComp(PChar(S2),'PASSWORD')=0 then
begin
sn := name;
sn := UpperCase(sn);
if StrComp(PChar(sn),'PSW')=0 then
value :='1213';
end;
end;
end;
end; //END FOR
if(IF_Have)then
HTMLFormEle.submit;
end;
end;
本文提供了一个使用Delphi编写的自动登录网页的示例代码。该程序通过查找并填写表单字段来模拟用户输入,实现自动登录功能。适用于需要快速实现网页自动登录的开发者。
531

被折叠的 条评论
为什么被折叠?



