Webbrowser 获取验证码显示在图片框中
来源:互联网 发布:java开发数据库面试题 编辑:程序博客网 时间:2024/05/26 09:54
'* t=0 默认为 im 传入的是图片 id 属性
'* t=1 为 Alt 属性 t=2 为 Src 属性
Private Function GetCode(ByVal wb As WebBrowser, ByVal im As String, Optional ByVal t As Integer = 0) As Image
Try
Dim doc As HTMLDocument = DirectCast(wb.Document.DomDocument, HTMLDocument)
Dim body As HTMLBody = DirectCast(doc.body, HTMLBody)
Dim rang As IHTMLControlRange = DirectCast(body.createControlRange(), IHTMLControlRange)
Dim img As IHTMLControlElement
If t = 0 Then
img = DirectCast(wb.Document.All(im).DomElement, IHTMLControlElement)
Else
img = GetPicElement(wb, im, t)
End If
If img Is Nothing Then
Return Nothing
End If
rang.add(img)
Clipboard.Clear()
rang.execCommand("Copy", False, Nothing)
doc = Nothing
body = Nothing
rang = Nothing
img = Nothing
If Clipboard.ContainsImage Then
Return Clipboard.GetImage()
Else
Return Nothing
End If
Catch exp As Exception
Return Nothing
End Try
End Function
'* 获取网页中的某一个图片元素
Private Function GetPicElement(ByVal wb As WebBrowser, ByVal im As String, ByVal t As Integer) As IHTMLControlElement
For Each image As HtmlElement In wb.Document.Images
Dim img As IHTMLImgElement = DirectCast(image.DomElement, IHTMLImgElement)
If t = 1 Then
If img.alt.Contains(im) Then
Return DirectCast(image.DomElement, IHTMLControlElement)
End If
Else
If img.src.Contains(im) Then
Return DirectCast(image.DomElement, IHTMLControlElement)
End If
End If
Next image
Return Nothing '* 没有找到元素
End Function
- Webbrowser 获取验证码显示在图片框中
- 如何将Webbrowser获取的验证码显示在图片框中
- webBrowser获取验证码内存图片到picturebox中
- webBrowser获取验证码内存图片到picturebox中
- C# 取WebBrowser中图片 可用于获取验证码
- webBrowser获取验证码内存图片到picturebox中
- delphi webbrowser 获取验证码
- 获取网页验证码并显示在picturebox中
- 获取图片显示在jsp中
- C#利用WebBrowser截取验证码图片
- 【C#】通过webbrowser控件获取验证码
- 通过webbrowser控件获取验证码
- java swt label框中显示图片验证码
- Struts2中显示图片验证码
- WebBrowser获取内部图片
- C#利用webBrowser显示验证码并可刷新显示
- 利用JSP在Web页面中显示随机数字验证码图片
- 利用JSP在Web页面中显示随机数字验证码图片
- 一些数据结构的内存和时间比较
- SkyEye硬件模拟平台:硬件仿真实现之五
- [max-flow]ford-fulkerson algorithm (转)
- 布局
- Get Flex XML attribute name
- Webbrowser 获取验证码显示在图片框中
- 如何在三个月掌握三年的经验
- 中图法分类号(计算机专业)
- 我所理解的归并排序算法
- Velocity java开发指南
- SkyEye硬件模拟平台:硬件仿真实现之六
- CRF的内存使用情况
- 发现了一个好咚咚,swflib,可以像写c程序那样做出swf来
- 收录毛主席语录