Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Not WebBrowser1.Busy Then For Each x In WebBrowser1.Document.All
If x.tagName = "IMG" Then
If InStr(x.src, "ValidatorCode.ashx?name=Comment") <> 0 Then
Set CtrlRange = WebBrowser1.Document.body.createControlRange()
CtrlRange.Add (x)
CtrlRange.execCommand ("Copy")
pic1.Picture = Clipboard.GetData
End If
End If
Next
End If
End Sub
Private Sub Command1_Click()
Dim vDoc, vtag
Dim i As Integer
Dim x, CtrlRange
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1
If LCase$(vDoc.All(i).tagName) = "input" Or LCase$(vDoc.All(i).tagName) = "textarea" Then
Set vtag = vDoc.All(i)
Select Case vtag.Name
Case "CommentCode"
vtag.Value = Text2.Text '验证码
Case "CommentText"
vtag.Value = Text1.Text '内容
Case "ComSend" '模拟 单击 发送
vtag.Click
End Select
End If
Next i
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.zaidudu.com/book/7902/index.aspx"
End Sub
单击 command1 就把 text1 和 text2 的内容发送到网页上,但是,每次都提示说,验证码错误。
请问:应该怎么解决呢?
If Not WebBrowser1.Busy Then For Each x In WebBrowser1.Document.All
If x.tagName = "IMG" Then
If InStr(x.src, "ValidatorCode.ashx?name=Comment") <> 0 Then
Set CtrlRange = WebBrowser1.Document.body.createControlRange()
CtrlRange.Add (x)
CtrlRange.execCommand ("Copy")
pic1.Picture = Clipboard.GetData
End If
End If
Next
End If
End Sub
Private Sub Command1_Click()
Dim vDoc, vtag
Dim i As Integer
Dim x, CtrlRange
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1
If LCase$(vDoc.All(i).tagName) = "input" Or LCase$(vDoc.All(i).tagName) = "textarea" Then
Set vtag = vDoc.All(i)
Select Case vtag.Name
Case "CommentCode"
vtag.Value = Text2.Text '验证码
Case "CommentText"
vtag.Value = Text1.Text '内容
Case "ComSend" '模拟 单击 发送
vtag.Click
End Select
End If
Next i
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.zaidudu.com/book/7902/index.aspx"
End Sub
单击 command1 就把 text1 和 text2 的内容发送到网页上,但是,每次都提示说,验证码错误。
请问:应该怎么解决呢?
验证码在哪?
On Error Resume Next
If URL = "http://www.zaidudu.com/user/login.aspx" Then
Dim vDoc, vtag
Dim i As Integer
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1
If UCase$(vDoc.All(i).tagName) = "INPUT" Then
Set vtag = vDoc.All(i)
Select Case vtag.Type
Case "text"
If vtag.Id = "username" Then vtag.Value = "test001" '帐号
Case "password"
If vtag.Id = "password" Then vtag.Value = "123456" '密码
Case "submit"
vtag.Click
Exit Sub
End Select
End If
Next i
End If
If URL = "http://www.zaidudu.com/User/LoginTran.aspx?GotoUrl=http://www.zaidudu.com" Then
WebBrowser1.Navigate "http://www.zaidudu.com/Book/5505/Index.aspx"
End If
If Not WebBrowser1.Busy Then
For Each x In WebBrowser1.Document.All
If x.tagName = "IMG" Then
If InStr(x.src, "ValidatorCode.ashx?name=Comment") <> 0 Then
Set CtrlRange = WebBrowser1.Document.body.createControlRange()
CtrlRange.Add (x)
CtrlRange.execCommand ("Copy")
Picture1.Picture = Clipboard.GetData
End If
End If
Next
End If
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.zaidudu.com/user/login.aspx"
End Sub
Private Sub Command1_Click()
Dim vDoc, vtag
Dim i As Integer
Dim x, CtrlRange
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1
If LCase$(vDoc.All(i).tagName) = "input" Or LCase$(vDoc.All(i).tagName) = "textarea" Then
Set vtag = vDoc.All(i)
Select Case vtag.Name
Case "CommentCode"
vtag.Value = Text2.Text '验证码
Case "CommentText"
vtag.Value = Text1.Text '内容
Case "ComSend" '模拟 单击 发送
vtag.Click
End Select
End If
Next i
End Sub
需要登陆才可以看到验证码,避免注册,我已经注册好了,写到代码里面了~~ 测试账号:test001 密码:123456
单击 command1 就把 text1 和 text2 的内容发送到网页上,但是,每次都提示说,验证码错误。 请问:应该怎么解决呢?
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)Dim frm As Form1
Set frm = New Form1
frm.Visible = True
Set ppDisp = frm.WebBrowser1.objectEnd Sub