救急:200分求网页自动填表和提交源码 ( 积分: 200 )

  • 主题发起人 主题发起人 yong_yu
  • 开始时间 开始时间
Y

yong_yu

Unregistered / Unconfirmed
GUEST, unregistred user!
朋友急着要偶做一个能自动填写网页信息并自动提交的小软件,但偶没做过TwebBrower的开发,那位弟兄有类似的源码,麻烦发给我一份: yong_yu@sohu.com ,先谢了.
 
朋友急着要偶做一个能自动填写网页信息并自动提交的小软件,但偶没做过TwebBrower的开发,那位弟兄有类似的源码,麻烦发给我一份: yong_yu@sohu.com ,先谢了.
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, Buttons;

type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
WebBrowser1: TWebBrowser;
Memo1: TMemo;
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses mshtml;
{$R *.dfm}

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);
var
i,j:integer;
doc:IHtmlDocument2;
elec:IHtmlElementCollection;
chele:IHtmlElement;
inputelement:IHtmlInputElement;
textareaelement:IHtmlTextAreaElement;
formelement:IHtmlFormElement;
begin
doc:=webbrowser1.document as IHtmlDocument2;
if doc=nil then exit;
memo1.Lines.Clear;
memo1.Text:=doc.body.outerText;
elec:=doc.all;

for i:=0 to elec.length-1 do
begin
chele:=elec.item(i,emptyparam) as IHtmlElement;
if chele.tagName='INPUT' then
try
inputelement:=elec.item(i,emptyParam) as IHtmlInputElement;
if inputelement.name='userid' then inputelement.value:='用户名';
if inputelement.name='passwd' then inputelement.value:='口令';
except
end;
end;
for j:=0 to elec.length-1 do
begin
chele:=elec.item(j,emptyparam) as IHtmlElement;
if chele.tagName='FORM' then
try
formelement:=elec.item(j,emptyparam) as Ihtmlformelement;
if formelement.name='loginForm' then
begin
formelement.submit;
//showmessage('ok');
end;
except
end;
end;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
webbrowser1.Navigate('http://www.abc.com/login.do');
end;

end.
 
谢谢 zhuxd,
再请教一下,我想查看网页的源码,并模拟 href 的点击,该如何实现?
 
呵呵,我解决问题了,谢谢!!!!
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部