最近经营淘宝店,卖QQ币。没事就写了个自动登陆的程序!
下面我把代码贴出来,欢迎指正。。。
procedure TForm1.Button2Click(Sender: TObject); var doc: IHTMLDocument2; denglu: OleVariant; begin tag:=0; WebBrowser1.Navigate('https://login.taobao.com'); while(tag=0) do Application.ProcessMessages; WebBrowser1.oleobject.Document.body.Scroll:='no'; Sleep(1000); try doc := WebBrowser1.Document as IHTMLDocument2; if doc = nil then Exit; denglu := doc.all.item('TPL_username_1', 0) as IHTMLElement2; denglu.Value := edit1.Text; //为文本框赋值 denglu := doc.all.item('TPL_password_1', 0) as IHTMLElement2; denglu.Value := edit2.Text; //为文本框赋值 denglu := doc.all.item('J_SubmitStatic',0) as IHTMLElement2; denglu.Click; //点击按钮,提交表单 except end; end;
标签:delphi
发表评论