use
clipbrd , mshtml
procedure TForm1.DomImg2Image(src:string;wb:TWebBrowser;img:TImage);
vari: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;
DomImg2Image('CheckCode?',wb1,img1);
本文介绍了一种使用 Delphi 从 Web 浏览器中指定图片元素进行抓取的方法,并将其转换为图像对象。该过程涉及定位图片源、复制到剪贴板及将内容加载到图像组件。
3172

被折叠的 条评论
为什么被折叠?



