vb中获取网页验证码,网页中有很多图片 5
DimvtagDimCtrlRangeForEachvtagInWebBrowser1.Document.AllIfvtag.tagName="IMG"ThenSetCt...
Dim vtag
Dim CtrlRange
For Each vtag In WebBrowser1.Document.All
If vtag.tagName = "IMG" Then
Set CtrlRange = WebBrowser1.Document.body.createControlRange()
CtrlRange.Add (vtag)
CtrlRange.execCommand ("Copy")
Set Image1.Picture = Clipboard.GetData
End If
Next
这个命令只能得到该网页最后一个图片,不能行到中间的验证码 展开
Dim CtrlRange
For Each vtag In WebBrowser1.Document.All
If vtag.tagName = "IMG" Then
Set CtrlRange = WebBrowser1.Document.body.createControlRange()
CtrlRange.Add (vtag)
CtrlRange.execCommand ("Copy")
Set Image1.Picture = Clipboard.GetData
End If
Next
这个命令只能得到该网页最后一个图片,不能行到中间的验证码 展开
2个回答
展开全部
'轿高李//放在form的通用处闭迟.
Private Type TGUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
'// 用来加载Internet上的图片
Private Declare Function OleLoadPicturePath Lib "oleaut32.dll" (ByVal szURLorPath As Long, ByVal punkCaller As Long, ByVal dwReserved As Long, ByVal clrReserved As OLE_COLOR, ByRef riid As TGUID, ByRef ppvRet As IPicture) As Long
'// 从Internet上加载念衡图片
Public Function LoadPicture(ByVal strFileName As String) As Picture
Dim IID As TGUID
With IID
.Data1 = &H7BF80980
.Data2 = &HBF32
.Data3 = &H101A
.Data4(0) = &H8B
.Data4(1) = &HBB
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H30
.Data4(6) = &HC
.Data4(7) = &HAB
End With
On Error GoTo LocalErr
OleLoadPicturePath StrPtr(strFileName), 0&, 0&, 0&, IID, LoadPicture
Exit Function
LocalErr:
Set LoadPicture = VB.LoadPicture(strFileName)
Err.Clear
End Function
用法与vb的loadpicture一样.
image.picture=loadpicture("")
Private Type TGUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
'// 用来加载Internet上的图片
Private Declare Function OleLoadPicturePath Lib "oleaut32.dll" (ByVal szURLorPath As Long, ByVal punkCaller As Long, ByVal dwReserved As Long, ByVal clrReserved As OLE_COLOR, ByRef riid As TGUID, ByRef ppvRet As IPicture) As Long
'// 从Internet上加载念衡图片
Public Function LoadPicture(ByVal strFileName As String) As Picture
Dim IID As TGUID
With IID
.Data1 = &H7BF80980
.Data2 = &HBF32
.Data3 = &H101A
.Data4(0) = &H8B
.Data4(1) = &HBB
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H30
.Data4(6) = &HC
.Data4(7) = &HAB
End With
On Error GoTo LocalErr
OleLoadPicturePath StrPtr(strFileName), 0&, 0&, 0&, IID, LoadPicture
Exit Function
LocalErr:
Set LoadPicture = VB.LoadPicture(strFileName)
Err.Clear
End Function
用法与vb的loadpicture一样.
image.picture=loadpicture("")
追问
谢谢,我现在用的是这个:
If InStr(objImage.src, "code.cn.img.php?c=") > 0 Then
Set objDoc = WebBrowser1.Document.body.CreateControlRange()
objDoc.Add objImage
objDoc.ExecCommand "Copy"
Image1.Picture = Clipboard.GetData
字数不行,不能写太多,新问题下拉选单怎么写,那个一点都不会
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询