我在csdn上看到有一种方法是:
Private Sub webSky_DownloadComplete()
On Error Resume Next
WebSky.Silent = True
Me.MousePointer = vbDefault
Dim x, CtrlRange
Dim sPath As String
sPath = App.Path
sPath = Left(sPath, InStr(sPath, vbNullChar) - 1)
If Len(sPath) > 3 Then sPath = sPath & "\"
If Trim(txtUser.Text) <> "" Then
gstrFileName = sPath & Trim(txtUser.Text) & "Code.bmp"
Else
gstrFileName = sPath & "TempCode.bmp"
End If
For Each x In WebSky.Document.All
If x.tagName = "IMG" Then
If x.src = "http://getCode.asp" Then '这里就是那个动态图片的连接了
WebSky.Stop
Set CtrlRange = WebSky.Document.body.createControlRange()
CtrlRange.Add (x)
CtrlRange.execCommand ("Copy")
SavePicture Clipboard.GetData, gstrFileName
end if
End If
Next
End Sub
但是这种方法只适合于 <img id="code" src="code.asp"> 这种类型的验证码我现在遇到的问题是,验证码是这样显示的:
<iframe src="checkcode.php?type=2" style="" id="iframe2" name="bb" width="75" height="25" frameborder="1" scrolling="no" align="middle" marginwidth="0" marginheight="0"></iframe>用上面的代码就会出错,麻烦帮我解决一下,谢谢!
Private Sub webSky_DownloadComplete()
On Error Resume Next
WebSky.Silent = True
Me.MousePointer = vbDefault
Dim x, CtrlRange
Dim sPath As String
sPath = App.Path
sPath = Left(sPath, InStr(sPath, vbNullChar) - 1)
If Len(sPath) > 3 Then sPath = sPath & "\"
If Trim(txtUser.Text) <> "" Then
gstrFileName = sPath & Trim(txtUser.Text) & "Code.bmp"
Else
gstrFileName = sPath & "TempCode.bmp"
End If
For Each x In WebSky.Document.All
If x.tagName = "IMG" Then
If x.src = "http://getCode.asp" Then '这里就是那个动态图片的连接了
WebSky.Stop
Set CtrlRange = WebSky.Document.body.createControlRange()
CtrlRange.Add (x)
CtrlRange.execCommand ("Copy")
SavePicture Clipboard.GetData, gstrFileName
end if
End If
Next
End Sub
但是这种方法只适合于 <img id="code" src="code.asp"> 这种类型的验证码我现在遇到的问题是,验证码是这样显示的:
<iframe src="checkcode.php?type=2" style="" id="iframe2" name="bb" width="75" height="25" frameborder="1" scrolling="no" align="middle" marginwidth="0" marginheight="0"></iframe>用上面的代码就会出错,麻烦帮我解决一下,谢谢!
iframe src="checkcode.php?type=2
iframe里面的内容应该不会变,你先去提取iframe里面的内容好了