高手请进!如何使用TWebbrowser来保存网页里验证码的图片!仅只需获取证码的图片流!谢谢

hatedeadlock 2007-03-12 07:11:53
如何使用TWebbrowser来保存网页里验证码的图片!仅只需获取证码的图片流!
我用这样的方式来做
procedure TForm1.Button5Click(Sender: TObject);
var
d2,D:IHTMLDocument2;
d1:IHTMLDocument;
e:IHTMLElement;
e2:IHTMLElement2;
cp:IHTMLControlRange;
img:IHTMLImgElement;
ce:IHTMLControlElement;
begin
try
D:= vCodeWeb.Document as IHTMLDocument2;
e:=d.body as IHTMLElement;
e2:=e as IHTMLElement2;
cp:=e2.createControlRange as IHTMLControlRange;
d2:= vCodeWeb.Document as IHTMLDocument2;
img:=d2.images.item('G',0) AS IHTMLImgElement;
ce:=img as IHTMLControlElement;
cp.add(ce);
cp.execCommand('Copy',false,0);
except
on e:Exception do
showmessage(e.Message);
end;
end;
结果是这样的 静态的图片没有问题,可是验证码的图片是由JSP,PHP,ASP动态生成的。HTML里是这样的 <IMG SRC="inc/code.asp"> 请问如何获取这个图片流。谢谢
...全文
1019 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
randb 2007-06-13
  • 打赏
  • 举报
回复
出售高级验证码识别引擎AdvOCR的全部Delphi源码,可准确识别新浪动网百度淘宝QQ等多种复杂验证码

输出为一个标准DLL,可供VB,VC,Delphi,C#.NET,VB.NET等多平台调用,其中用到了破解版本的Transym OCR识别引擎(国外最强悍的商业OCR),另外加上独具特色的边缘检测字符分离、旋转倾斜纠正和通用字符匹配算法(无论字体和大小),使得该引擎对于像新浪、动网、淘宝、QQ、百度等多种验证码均有80%以上的识别率,是目前国内非常出色的验证码识别引擎。附详细的调用实例和代码注释。价格600元以内,可商议。联系QQ:631753663

效果怎么样一试就知道。
DEMO下载 (电信)www.purejoy.cn/soft/advocr.rar
     (网通)cnc.purejoy.cn/soft/advocr.rar
sois2000 2007-04-29
  • 打赏
  • 举报
回复
OK
pilicat 2007-03-26
  • 打赏
  • 举报
回复
嗯,不错啊,学习。
hatedeadlock 2007-03-15
  • 打赏
  • 举报
回复
我上次在这个论坛上拷贝的,应该是你写的。
能不能帮忙想想其他的方法!谢谢
scyaan 2007-03-15
  • 打赏
  • 举报
回复
哈哈,你的程序怎么和我写的那么相?
http://community.csdn.net/Expert/TopicView3.asp?id=5295232

只要得到img的id就没问题。但这句img:=d2.images.item('G',0) AS IHTMLImgElement;怕要改改。
把网页原址贴出来看看。
hatedeadlock 2007-03-14
  • 打赏
  • 举报
回复
里面定义的参数不是很清楚
hatedeadlock 2007-03-14
  • 打赏
  • 举报
回复
withcsharp 大哥,能不能发一份完整的代码给我,谢谢
withcsharp 2007-03-14
  • 打赏
  • 举报
回复
俺 以前 刷票的程序

var
code: string;
Buf: string;
ok: Boolean;
begin
ok := False;
try
Cookielist.Clear;
DataOut.Clear;
ms.Clear;
HttpCli1.Cookie := '';
HttpCli1.URL := 'http://www.aspoo.com/Mb_Match/SoftShow.Asp?SoftID=94';
Label3.Caption := 'open ......';
Repaint;
try
HttpCli1.OnHeaderEnd := HttpCli1HeaderEnd;
HttpCli1.Get;
except
end;
HttpCli1.OnHeaderEnd := nil;
if Cookielist.Count > 0 then
begin
HttpCli1.Cookie := Cookielist[Cookielist.Count - 1];
ms.Clear;
HttpCli1.URL := 'http://www.aspoo.com/Inc/Cl_GetCode.asp?type=VoteCode';
Label3.Caption := 'get bmp ......';
Repaint;

try
HttpCli1.Get;
except
end;
ms.Seek(0, soFromBeginning);
bmp.LoadFromStream(ms);
PaintBox1.Repaint;
code := getCode_Bmp(bmp, 4, PointRecList);
Label2.Caption := 'code:' + code;

HttpCli1.URL := 'http://www.aspoo.com/Mb_Match/SoftShow.asp?softid=94';
Buf := 'Action=vote&VoteCode=' + code + '&submit=%CD%B6%C6%B1';
DataOut.Clear;
if Length(Buf) > 0 then { Check if some data to post }
DataOut.Write(Buf[1], Length(Buf));
DataOut.Seek(0, soFromBeginning);
HttpCli1.SendStream := DataOut;
ms.Clear;
Label3.Caption := 'post ......';
Repaint;
HttpCli1.Post;
SetLength(Buf, ms.size);
ms.Seek(0, soFromBeginning);
ms.Read(Buf[1], ms.size);
Label3.Caption := Buf;
Caption := buf;
ok := pos('成功', buf) > 1;
end;
except
end;
if ok then
Inc(okCount)
else
Inc(errCount);
Label4.Caption := Format('okCount:%d ; errCount:%d ', [okCount, errCount]);

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧