delphi 怎么控制IE浏览器 DELPHI 怎么控制IE浏览器.自动填表.提交.之类的..急求.麻烦帮帮忙!~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 !_! 这两种都不行..就是要控制IE浏览器..不要用D里面的控件 webbrowser或者直接使用idhttp都可以做到自动填表.提交干嘛非得直接控制IE呢外挂控制ie,麻烦还不稳定 控制浏览器?控制控制浏览器的打开、关闭及输入的URL? 自動填表uses MSHTML; procedure TForm1.Button1Click(Sender: TObject); var vHTMLDocument: IHTMLDocument2; vHTMLElementCollection: IHTMLElementCollection; vHTMLInputElement: IHTMLInputElement; vHTMLSelectElement: IHTMLSelectElement; // vHTMLFormElement: IHTMLFormElement; begin vHTMLDocument := WebBrowser1.Document as IHTMLDocument2; vHTMLElementCollection := vHTMLDocument.all; vHTMLInputElement := vHTMLElementCollection.item( 'text_name ', 0) as IHTMLInputElement; if Assigned(vHTMLInputElement) then vHTMLInputElement.value := '自动填表 '; vHTMLSelectElement := vHTMLElementCollection.item( 'select_name ', 0) as IHTMLSelectElement; if Assigned(vHTMLSelectElement) then vHTMLSelectElement.selectedIndex := 1; // vHTMLFormElement := vHTMLElementCollection.item( 'form1 ', 0) as IHTMLFormElement; // if Assigned(vHTMLFormElement) then // vHTMLFormElement.submit; end; 提交可以使用clientsocket,先截获你提交表单的包信息,然后构造http头//Http头信息 sends:='POST /Expert/reply.asp HTTP/1.1'+#13#10; sends:=sends+'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*'+#13#10; sends:=sends+'Accept-Language: zh-cn'+#13#10; sends:=sends+'Content-Type: application/x-www-form-urlencoded'+#13#10; sends:=sends+'Accept-Encoding: gzip, deflate'+#13#10; sends:=sends+'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'+#13#10; sends:=sends+'Host: expert.csdn.net'+#13#10; sends:=sends+'Cache-Control: no-cache'+#13+#10; //构造Cookie信息 if edit1.text<>'' then begin url.InputString :=trim(edit1.Text); sendp:='username='+url.Encode ; sendc:='csdnname='+url.Encode ; end; if edit2.text<>'' then begin url.InputString :=trim(edit2.Text); sendp:=sendp+';userid='+url.Encode; sendc:=sendc+'&csdnpassword='+url.Encode ; end; if edit3.text<>'' then begin url.InputString :=trim(edit3.Text); sendp:=sendp+';aszx='+url.Encode; end; sends:=sends+'Cookie: '+sendp+#13+#10; //发送的内容 url.inputstring:=trim(edit4.text); sendc:=sendc+'&Topicid='+url.Encode; url.InputString :=trim(memo1.Text); sendc:=sendc+'&ReplyContent='+url.Encode; sendc:=sendc+'&xmlReply=aaaaa'; sends:=sends+'Content-Length: '+inttostr(length(sendc))+#13#10; sends:=sends+'Connection: Keep-Alive'+#13+#10+#13#10 +sendc; memo2.Lines.Clear; memo2.Lines.Add(sends); clientsocket1.Socket.SendText(sends); /////////////////////////////////////////////////////////////////////////////////////提交帖子截获的包信息: Topicid=1761293&xmlReply=aaaaa&csdnname=&csdnpassword=&ReplyContent=test10.104.9.30(2807)->10.104.9.30(80) POST /Expert/reply.asp HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */* Referer: http://expert.csdn.net/Expert/xsl/Reply_Xml.asp?Topicid=1761293 Accept-Language: zh-cn Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Host: expert.csdn.net Content-Length: 72 Connection: Keep-Alive Cache-Control: no-cache Cookie: ASPSESSIONIDQQQTRARD=DNLFEPPAAODHIOGCMLPPIFKP; room=0; username=dashi888; speaknum=0; speaktime=2003%2D5%2D14+16%3A48%3A06; adminok=True; userid=487815; info1=0; remenber=0; mid=476831; m%5Ftype=1; aszx=0a727a0323ec0c60e5c113526be5ba02 楼主在网上搜下iwebbrowser2接口,就是专门解决你这个问题的。 var IE: Variant;begin IE := CreateOleObject('InternetExplorer.Application'); IE.Visible := true; //可见 IE.Navigate(URL); 用wpe工具,你在网页提交,然后抓包看看提交内容,然后用idhttp去模拟提交 rug 在webbrowser上也可以,但是限制比较多,比如有的是安全组件,用javascript时不行的,需要遍历组件然后发送字符消息,有的还无法找到 楼主想要的是控制已经打开的IE浏览器,控制里面的操作吧,那应是findwindow,sendmessage一系列的操作吧,应该很复杂 已经说得很明白了,此人不想用Delphi的控件,估计就是个整木马的,很在意编译出的体积 请问类TeThemeForm在哪一个控件包中啊,在哪里好下载的啊,谢谢! 有关listView和数据库的问题,在线急等,分数不是问题! 關於DBChart的簡單問題, 百分求 C/S 初级应用程序 DELPHI里如何设置一个文件夹属性为隐藏呢?在线等待 关于DBClient adoquery使用cluseserver和cluseclient的效率问题 什么叫做组件定制开发? 请问怎么写用于runtime时的运行包??? delphi dataset not in edit or insert mode错误 新手请教 怎么用第三方控件 改变 窗体 按钮的皮肤? 会什么用Delphi的人少呢?
都可以做到自动填表.提交
干嘛非得直接控制IE呢
外挂控制ie,麻烦还不稳定
uses MSHTML; procedure TForm1.Button1Click(Sender: TObject);
var
vHTMLDocument: IHTMLDocument2;
vHTMLElementCollection: IHTMLElementCollection;
vHTMLInputElement: IHTMLInputElement;
vHTMLSelectElement: IHTMLSelectElement;
// vHTMLFormElement: IHTMLFormElement;
begin
vHTMLDocument := WebBrowser1.Document as IHTMLDocument2;
vHTMLElementCollection := vHTMLDocument.all;
vHTMLInputElement := vHTMLElementCollection.item( 'text_name ', 0) as IHTMLInputElement;
if Assigned(vHTMLInputElement) then
vHTMLInputElement.value := '自动填表 ';
vHTMLSelectElement := vHTMLElementCollection.item( 'select_name ', 0) as IHTMLSelectElement;
if Assigned(vHTMLSelectElement) then
vHTMLSelectElement.selectedIndex := 1;
// vHTMLFormElement := vHTMLElementCollection.item( 'form1 ', 0) as IHTMLFormElement;
// if Assigned(vHTMLFormElement) then
// vHTMLFormElement.submit;
end;
//Http头信息
sends:='POST /Expert/reply.asp HTTP/1.1'+#13#10;
sends:=sends+'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*'+#13#10;
sends:=sends+'Accept-Language: zh-cn'+#13#10;
sends:=sends+'Content-Type: application/x-www-form-urlencoded'+#13#10;
sends:=sends+'Accept-Encoding: gzip, deflate'+#13#10;
sends:=sends+'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'+#13#10;
sends:=sends+'Host: expert.csdn.net'+#13#10;
sends:=sends+'Cache-Control: no-cache'+#13+#10;
//构造Cookie信息
if edit1.text<>'' then
begin
url.InputString :=trim(edit1.Text);
sendp:='username='+url.Encode ;
sendc:='csdnname='+url.Encode ;
end;
if edit2.text<>'' then
begin
url.InputString :=trim(edit2.Text);
sendp:=sendp+';userid='+url.Encode;
sendc:=sendc+'&csdnpassword='+url.Encode ;
end;
if edit3.text<>'' then
begin
url.InputString :=trim(edit3.Text);
sendp:=sendp+';aszx='+url.Encode;
end;
sends:=sends+'Cookie: '+sendp+#13+#10;
//发送的内容
url.inputstring:=trim(edit4.text);
sendc:=sendc+'&Topicid='+url.Encode;
url.InputString :=trim(memo1.Text);
sendc:=sendc+'&ReplyContent='+url.Encode;
sendc:=sendc+'&xmlReply=aaaaa';
sends:=sends+'Content-Length: '+inttostr(length(sendc))+#13#10;
sends:=sends+'Connection: Keep-Alive'+#13+#10+#13#10 +sendc;
memo2.Lines.Clear;
memo2.Lines.Add(sends);
clientsocket1.Socket.SendText(sends); /////////////////////////////////////////////////////////////////////////////////////
提交帖子截获的包信息: Topicid=1761293&xmlReply=aaaaa&csdnname=&csdnpassword=&ReplyContent=test10.104.9.30(2807)->10.104.9.30(80)
POST /Expert/reply.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*
Referer: http://expert.csdn.net/Expert/xsl/Reply_Xml.asp?Topicid=1761293
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: expert.csdn.net
Content-Length: 72
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASPSESSIONIDQQQTRARD=DNLFEPPAAODHIOGCMLPPIFKP; room=0; username=dashi888; speaknum=0; speaktime=2003%2D5%2D14+16%3A48%3A06; adminok=True; userid=487815; info1=0; remenber=0; mid=476831; m%5Ftype=1; aszx=0a727a0323ec0c60e5c113526be5ba02
IE: Variant;
begin
IE := CreateOleObject('InternetExplorer.Application');
IE.Visible := true; //可见
IE.Navigate(URL);