如何自动提交表单!(100分)

  • 主题发起人 主题发起人 Banky
  • 开始时间 开始时间
B

Banky

Unregistered / Unconfirmed
GUEST, unregistred user!
有个网页,需要输入一些数据,然后提交
如何用DELPHI程序自动输入数据,并自动提交

我看了前面的一些,但不得要领,哪位能详细说明,感激
网页是 index.aspx
 
呵呵,是不是想干坏事啊?
 
不是,公司每天要通过 浏览器 输入一些重复 或有规律的东西
我想编程自动实现,无奈从未接触这些东西。。。。
 
uses
MSHTML_TLB;

// first navigate to tipspage

procedure TForm1.Button1Click(Sender: TObject);
begin
Webbrowser1.Navigate('http://www.swissdelphicenter.ch/en/tipsuchen.php');
end;

// Try to access IE instance and fill out the search field with
// a text and click the search button

procedure TForm1.Button3Click(Sender: TObject);
var
hIE: HWND;
ShellWindow: IShellWindows;
WB: IWebbrowser2;
spDisp: IDispatch;
IDoc1: IHTMLDocument2;
Document: Variant;
k, m: Integer;
ovElements: OleVariant;
i: Integer;
begin
ShellWindow := CoShellWindows.Create;
// get the running instance of Internet Explorer
for k := 0 to ShellWindow.Count do
begin
spDisp := ShellWindow.Item(k);
if spDisp = nil then Continue;
// QueryInterface determines if an interface can be used with an object
spDisp.QueryInterface(iWebBrowser2, WB);

if WB <> nil then
begin
WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
if iDoc1 <> nil then
begin
WB := ShellWindow.Item(k) as IWebbrowser2;
begin
Document := WB.Document;

// count forms on document and iterate through its forms
for m := 0 to Document.forms.Length - 1 do
begin
ovElements := Document.forms.Item(m).elements;
// iterate through elements
for i := 0 to ovElements.Length - 1 do
begin
// when input fieldname is found, try to fill out
try
if (CompareText(ovElements.item(i).tagName, 'INPUT') = 0) and
(CompareText(ovElements.item(i).type, 'text') = 0) then
begin
ovElements.item(i).Value := 'FindWindow';
end;
except
end;
// when Submit button is found, try to click
try
if (CompareText(ovElements.item(i).tagName, 'INPUT') = 0) and
(CompareText(ovElements.item(i).type, 'SUBMIT') = 0) and
(ovElements.item(i).Value = 'Search') then // Suchen für German
begin
ovElements.item(i).Click;
end;
except
end;
end;
end;
end;
end;
end;
end;
end;
 
请参考我回答过的一个类似问题:
http://delphibbs.com/delphibbs/dispq.asp?lid=2429833
 
呵呵,用ics的httpcli,然后加个timer 很简单的
 
netlangz 你好
我用 httpcli 很容易取到网页,可是我不知如何提交,例子里好象没有
具体我想这样,先登陆,再看网页登陆是否成功(或下载完成),再填数据,提交
要涉及到 cookies
我用webbrower可以实现,但图片会载下来,没用,慢了些,而且我仅仅想把数据提上去,不看
谢谢
 
后退
顶部