使用EPX Studio 7.0 下载网站验证码

 1 implementation
 2 
 3 var Document_: DispHTMLDocument; //用于处理网页文档对象
 4       EPX: IExcelPanelXDisp;
 5 
 6 procedure TForm1.FormShow(Sender: TObject);
 7 begin
 8     EPX := ExcelPanelX1.OleObject;        //赋值
 9     EPX.ActiveDHtml := False;
10     EPX.EnableEvent := True;
11     EPX.ActiveDHtml := True;
12     EPX.Navigate(UserID, True);
13     Document_ := EPX.HtmlDocument;
14     ViewCode(1);
15 end;
 1 procedure TForm1.ViewCode(aty :Integer);
 2 var body,img,range: Variant;
 3     imgFile: string;
 4 begin
 5   img := Document_.getElementById('yzm').nextSibling.nextSibling;
 6   if aty = 1 then
 7   begin
 8     img.Click(0);
 9     this.Sleep(800);
10   end;
11   body := Document_.body;
12   range := body.createControlRange(0);
13   range.add(img);
14   range.execCommand('Copy');
15   //获取 Windows 的临时文件夹路径,返回的路径最后不带“\”。
16   //获取一个形式如“AA8CBB42-703C-47B9-B959-8E8EBAFA003E” 的 36 位长度的具有“不重复”特征的字符串,一般用于做数据库的 ID 字段内容使用。
17   imgFile := this.GetWindowsTempPath + '\' + this.GuidString + '.png';
18   this.SaveClipboardToFile(imgFile,2);
19   if this.FileExists[imgFile] then
20   begin
21     Image1.Picture.LoadFromFile(imgFile);
22     this.DeleteFile(imgFile);
23   end;
24 end;
1 procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
2 begin
3   EPX.FreeMe;
4   if CommandLine._DesignMode = 'False' then
5   begin
6     this.KillProcess('',0,0,0);
7   end;
8 end;

猜你喜欢

转载自www.cnblogs.com/xenli/p/12460216.html