积极答复者
请教一下webbrowser中如果取得iframe中的验证码图片,并保存到本地?

问题
-
https://oauth.taobao.com/authorize?response_type=token&client_id=23128046 这个网址应该是内嵌OAUTH2.0 单点登录的,用帐户密码输入错几次,验证码就会出来,我是想怎么样能把这个验证码保存成本地的一个图片文件呢?请知道的高人告诉一下,谢谢了!
相信自己,坚持下去。
答案
-
你好,
只针对你的存图片来说,得看你想用什么代码来获取,如果C#和WinForm的话:
mshtml.IHTMLWindow2 可以获取frame和里面图片的可能source,类似这里,但是我不确定它的图片会不会是在他自己服务器上的,说不定你获取到的只是一个没用的路径。硬要存的话可能你只能截全屏之类的。MVP说的挺有道理的,你要不试试去查询下淘宝的API有没有相关的东西?
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已建议为答案 Barry Wang 2015年7月9日 1:51
- 已标记为答案 CaillenModerator 2015年7月9日 2:14
-
引入
using mshtml;
使用com组件来获取
HtmlElement imgeHtmlElement = webBrowser1.Document.GetElementById("code"); //通过id查找该验证码所在元素位置
HTMLDocument doc = (HTMLDocument)this.webBrowser1.Document.DomDocument;
HTMLBody body = (HTMLBody)doc.body;
IHTMLControlRange range = (IHTMLControlRange)body.createControlRange();
IHTMLControlElement imgICE = (IHTMLControlElement)imgeHtmlElement.DomElement; //图片地址
range.add(imgICE);
range.execCommand("Copy", false, null); //复制到剪贴板
Image vcCodeImage = Clipboard.GetImage(); //得到image图像//剩下的就是写入文件的代码了,你自己写
- 已建议为答案 Barry Wang 2015年7月9日 1:51
- 已标记为答案 CaillenModerator 2015年7月9日 2:14
全部回复
-
-
你好,
只针对你的存图片来说,得看你想用什么代码来获取,如果C#和WinForm的话:
mshtml.IHTMLWindow2 可以获取frame和里面图片的可能source,类似这里,但是我不确定它的图片会不会是在他自己服务器上的,说不定你获取到的只是一个没用的路径。硬要存的话可能你只能截全屏之类的。MVP说的挺有道理的,你要不试试去查询下淘宝的API有没有相关的东西?
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已建议为答案 Barry Wang 2015年7月9日 1:51
- 已标记为答案 CaillenModerator 2015年7月9日 2:14
-
引入
using mshtml;
使用com组件来获取
HtmlElement imgeHtmlElement = webBrowser1.Document.GetElementById("code"); //通过id查找该验证码所在元素位置
HTMLDocument doc = (HTMLDocument)this.webBrowser1.Document.DomDocument;
HTMLBody body = (HTMLBody)doc.body;
IHTMLControlRange range = (IHTMLControlRange)body.createControlRange();
IHTMLControlElement imgICE = (IHTMLControlElement)imgeHtmlElement.DomElement; //图片地址
range.add(imgICE);
range.execCommand("Copy", false, null); //复制到剪贴板
Image vcCodeImage = Clipboard.GetImage(); //得到image图像//剩下的就是写入文件的代码了,你自己写
- 已建议为答案 Barry Wang 2015年7月9日 1:51
- 已标记为答案 CaillenModerator 2015年7月9日 2:14