S
sury8
Unregistered / Unconfirmed
GUEST, unregistred user!
全部代码如下 编译获取的是阿里巴巴的验证码,但是我现在遇到的是烽火战国里面的验证码 <img id="globleValidate_imgVerify" src="http://ptlogin2.qq.com/getimage?aid=36000101&'+Math.random();" width="130" height="53" /> 这个验证码怎么取呢?id="globleValidate_imgVerify" 如果用后面的src的话 验证码官方没弹出 你就获取一次它就会得到一次 那就不知道到底什么时候出的验证码 也就没了意义了unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, OleCtrls, SHDocVw, StdCtrls,clipbrd,mshtml,ActiveX;type TForm1 = class(TForm) Button1: TButton; WebBrowser1: TWebBrowser; Image1: TImage; Button2: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure WebBrowser1DownloadComplete(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure DomImg2Image(src:string;wb:TWebBrowser;img:TImage);var i:Integer; rang:IHTMLControlRange;begin for i:=0 to IHTMLDocument2(wb.Document).images.length-1 do if Pos(src,(IHTMLDocument2(wb.Document).images.item(i,EmptyParam)as IHTMLElement).getAttribute('src',0))>0 then begin rang:=((IHTMLDocument2(wb.Document).body as HTMLBody).createControlRange)as IHTMLControlRange; rang.add(IHTMLDocument2(wb.Document).images.item(i,EmptyParam)as IHTMLControlElement); rang.execCommand('Copy',False,0); try img.Picture.Assign(ClipBoard)except end; break; end;end;procedure TForm1.Button1Click(Sender: TObject);begin WebBrowser1.Navigate('http://china.alibaba.com/member/join.htm');end;procedure TForm1.FormCreate(Sender: TObject);begin OleInitialize(nil);end;procedure TForm1.FormDestroy(Sender: TObject);begin OleUninitialize;end;procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);begin DomImg2Image('checkcode?',TWebBrowser(Sender),Image1);end;end.