請問一下
procedure TForm1.Button2Click(Sender: TObject);
var
i:Integer;
rang1:IHTMLControlRange;
s1:string;
begin
try
s1 := (IHTMLDocument2(webbrowser2.Document).images.item('signup_join_beanfun_signup_samplecaptcha_CaptchaImage',EmptyParam) as IHTMLElement).getAttribute('src',0);
rang1:=((IHTMLDocument2(webbrowser2.Document).body as HTMLBody).createControlRange)as IHTMLControlRange;
rang1.add(IHTMLDocument2(webbrowser2.Document).images.item('signup_join_beanfun_signup_samplecaptcha_CaptchaImage',EmptyParam)as IHTMLControlElement);
rang1.execCommand('Copy',False,0);
image1.Picture.Assign(ClipBoard);
except
end;end;我的SRC 他是這樣
src='LanapCaptcha.aspx?get=image&c=signup_join_beanfun_signup_samplecaptcha&t=d10d9114a3784d8eb46a70e752c6aea4&s=B%2bx0RN36Kv%2bKylW0opJhn%2fDf5Dsnpq1Hri9SwrOQS8I%3d'都是不同的 我要怎麼輸入這個SRC呢?
procedure TForm1.Button2Click(Sender: TObject);
var
i:Integer;
rang1:IHTMLControlRange;
s1:string;
begin
try
s1 := (IHTMLDocument2(webbrowser2.Document).images.item('signup_join_beanfun_signup_samplecaptcha_CaptchaImage',EmptyParam) as IHTMLElement).getAttribute('src',0);
rang1:=((IHTMLDocument2(webbrowser2.Document).body as HTMLBody).createControlRange)as IHTMLControlRange;
rang1.add(IHTMLDocument2(webbrowser2.Document).images.item('signup_join_beanfun_signup_samplecaptcha_CaptchaImage',EmptyParam)as IHTMLControlElement);
rang1.execCommand('Copy',False,0);
image1.Picture.Assign(ClipBoard);
except
end;end;我的SRC 他是這樣
src='LanapCaptcha.aspx?get=image&c=signup_join_beanfun_signup_samplecaptcha&t=d10d9114a3784d8eb46a70e752c6aea4&s=B%2bx0RN36Kv%2bKylW0opJhn%2fDf5Dsnpq1Hri9SwrOQS8I%3d'都是不同的 我要怎麼輸入這個SRC呢?
解决方案 »
- Scrollbar怎么设置pagesize,Enabled.
- 不下载文件的前提下,如何判断远程URL的文件是否发生改变?
- 班主,能否将去年到今年的顶置贴的链接贴出?
- 有关DBGrid的使用(给高手加分不小气)
- delhpi做的dll给VC用的问题
- listview的问题
- 帮帮忙,不然是话,真的混不下去了!!救人一命胜造七级佛屠 关于ADO事务处理!我老是搞不出来!
- 读串口的数据到缓冲 区,再取出来,老是出错!问题在哪儿?
- 请教报表中QRDBText的显示问题。
- 【cxGrid】的Footer行中的合计数中的汉字怎么导出到excel ?
- 关于delphi中webbrowers应用问题
- 字段少记录多用什么来分栏显示好?
单元文件unit Unit11;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtCtrls;type
TForm11 = class(TForm)
btn1: TButton;
img1: TImage;
wb1: TWebBrowser;
btn2: TButton;
mmo1: TMemo;
edt1: TEdit;
procedure FormCreate(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form11: TForm11;implementation
uses ActiveX, wininet, mshtml, Clipbrd;
{$R *.dfm}procedure DomImg2Image(id:string; wb:TWebBrowser; img:TImage );
var
rang:IHTMLControlRange;
begin
rang:=((IHTMLDocument2(wb.Document).body as HTMLBody).createControlRange)as
IHTMLControlRange;
rang.add(IHTMLDocument2(wb.Document).images.item(id,EmptyParam)as
IHTMLControlElement);
rang.execCommand('Copy',False,0);
img.Picture.Assign(ClipBoard);
end;procedure TForm11.btn1Click(Sender: TObject);
var
i:Integer;
rang:IHTMLControlRange;
begin
//遍历图片元素, 在memo中显示Img的ID和src属性
mmo1.clear;
for i:= 0 to IHTMLDocument2(wb1.Document).images.length-1 do
begin
mmo1.lines.add((IHTMLDocument2(wb1.Document).images.item(i,EmptyParam)as
IHTMLElement).getAttribute('id',0));
mmo1.lines.add((IHTMLDocument2(wb1.Document).images.item(i,EmptyParam)as
IHTMLElement).getAttribute('src',0));
end;
end;procedure TForm11.btn2Click(Sender: TObject);
begin
//edt1.Text是Img的ID值, webbrowse对象, TImage
DomImg2Image(edt1.Text, wb1, img1);
end;procedure TForm11.FormCreate(Sender: TObject);
begin
wb1.Navigate('c:\aa.html');
end;end.aa.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<img id='signup_join_beanfun_signup_samplecaptcha_CaptchaImage' src='http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif' alt='CAPTCHA code image' />
<img src='http://info-database.csdn.net/Upload/2012-10-08/amd-475-60-1008.jpg' alt='重新取得' /></body>
</html>
DomImg2Image(edt1.Text, wb1, img1);
EDT1.text 的值是要打上 網頁要查的原始碼圖片 ID ??
DomImg2Image(edt1.Text, wb1, img1);
------------------------------------------------------------
我写的aa.html中, Img元素的ID是'signup_join_beanfun_signup_samplecaptcha_CaptchaImage'
如下所示:
DomImg2Image('signup_join_beanfun_signup_samplecaptcha_CaptchaImage', wb1, img1)