Delphi实现网页表单数据的自动提交 ( 积分: 100 )

  • 主题发起人 主题发起人 mysales
  • 开始时间 开始时间
M

mysales

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下,运行时就会报错,请高手帮忙!<br>unit&nbsp;Unit1;<br><br>interface<br><br>uses<br>&nbsp;&nbsp;Windows,&nbsp;Messages,&nbsp;SysUtils,&nbsp;Variants,&nbsp;Classes,&nbsp;Graphics,&nbsp;Controls,&nbsp;Forms,<br>&nbsp;&nbsp;Dialogs,&nbsp;OleCtrls,&nbsp;SHDocVw,&nbsp;StdCtrls,&nbsp;mshtml;<br><br>type<br>&nbsp;&nbsp;TForm1&nbsp;=&nbsp;class(TForm)<br>&nbsp;&nbsp;&nbsp;&nbsp;Button1:&nbsp;TButton;<br>&nbsp;&nbsp;&nbsp;&nbsp;WebBrowser1:&nbsp;TWebBrowser;<br>&nbsp;&nbsp;&nbsp;&nbsp;Edit1:&nbsp;TEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;Edit2:&nbsp;TEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;Edit3:&nbsp;TEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Button1Click(Sender:&nbsp;TObject);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;FormCreate(Sender:&nbsp;TObject);<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Private&nbsp;declarations&nbsp;}<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Public&nbsp;declarations&nbsp;}<br>&nbsp;&nbsp;end;<br><br>var<br>&nbsp;&nbsp;Form1:&nbsp;TForm1;<br><br>implementation<br><br>{$R&nbsp;*.dfm}<br><br>procedure&nbsp;TForm1.Button1Click(Sender:&nbsp;TObject);<br>var<br>Doc:IHTMLDocument2;<br>input:OleVariant;<br>userinputelement,pwdinputelement:ihtmlinputelement;<br>begin<br>doc:=webbrowser1.document&nbsp;as&nbsp;ihtmldocument2;<br>userinputelement:=(doc.all.item('user',0)&nbsp;as&nbsp;ihtmlinputelement);<br>userinputelement.value:=edit1.text;<br>pwdinputelement:=(doc.all.item('password',0)&nbsp;as&nbsp;ihtmlinputelement);<br>pwdinputelement.value:=edit2.text;<br>input:=doc.all.item('submit',0);<br>input.click;<br>end;<br>procedure&nbsp;TForm1.FormCreate(Sender:&nbsp;TObject);<br>begin<br>WebBrowser1.Navigate('http://intra.zhenshang.com');<br>end;<br><br>end.
 
自己顶一下&nbsp;&nbsp;现在论坛里的高手都在睡觉吗?
 
查一下离线资料,你的这个问题在以前的贴子里有很多<br>另外,你具体的错误内容也不说,怎么好分析,代码看多了眼睛不舒服的,有经验的话直接看错误内容应该就知道个八九不离十了
 
改用&nbsp;Http&nbsp;协议提交。效率会比你这现在这个高很多.
 
后退
顶部