怎么判断VB webbrowser 提交后是否成功
如何判断VB webbrowser 提交后是否成功
我在一个网站自动注册了一些帐号, 中间一些没有注册到,现在想写一个程序,将已注册到的帐号写入数据库. 但是遇到的问题是: 输入 用户名和密码 提交后, 如果登陆成功了很好判断, 如果是没有注册到的帐号,则登陆失败,则判断不了.我的源码如下:
Private Sub Form_Load()
Web1.Navigate "http://www.youcall.com/zh/user/login"
While Web1.ReadyState <> 4
DoEvents
Wend
End Sub
Private Sub Command2_Click()
Set dblogin = OpenDatabase(App.Path + "\Db1.mdb", False, False, "MS Access;")
Set rs = dblogin.OpenRecordset("select * from user1")
Set vdoc = Web1.Document
For j = 1 To 100
username1 = "dm00" & j
vdoc.Forms(0).All("email").Value = username1
vdoc.Forms(0).All("password").Value = "789789"
vdoc.Forms(0).submit
While Web1.ReadyState <> 4
DoEvents
Wend
'问题就出在验证失败的代码, 因如果失败, 网址不会跳转,会提示一个错误. 但是"错误"提示还未出现,下面的代码就已经执行了,所以就判断不了.
怎样能让下面的代码发生在页面完全下载了之后执行?
'-----------------判断登陆失败代码, --------------
strhtml = ""
For Each i In vdoc.All
If TypeName(i) = "HTMLParaElement" Then
strhtml = i.innerText
' MsgBox STRHTML
mypos = InStr(1, strhtml, "错误", 1)
If mypos > 0 Then
unit = Mid(strhtml, mypos + 2, 4)
MsgBox unit
Label3.Caption = strhtml
Exit For
GoTo abc
End If
End If
Next i
'---------登陆成功,页面跳转---------------------------------
While Web1.LocationURL <> "http://www.youcall.com/zh/call/init"
DoEvents
Wend
While Web1.ReadyState <> 4
DoEvents
Wend
strhtml = ""
For Each i In vdoc.All
If TypeName(i) = "HTMLParaElement& 丢个板砖[0] 引用 举报 管理 TOP 回复次数:5
------解决方案--------------------
那就是判断当前地址没有变化而且网页上出现了错误提示.否则为成功登录
IF Web1.LocationURL = "http://www.youcall.com/zh/user/login" THEN
For Each i In vdoc.All
If TypeName(i) = "HTMLParaElement" Then
strhtml = i.innerText
mypos = InStr(1, strhtml, "错误", 1)
If mypos > 0 Then
Failure=1
Exit For
elseif Web1.LocationURL = "http://www.youcall.com/zh/call/init"
Failure=0
End If
End If
Next i
ENDIF
------解决方案--------------------
不用谢拉,大家相互学习了
问题解决就即时结贴吧.........
我在一个网站自动注册了一些帐号, 中间一些没有注册到,现在想写一个程序,将已注册到的帐号写入数据库. 但是遇到的问题是: 输入 用户名和密码 提交后, 如果登陆成功了很好判断, 如果是没有注册到的帐号,则登陆失败,则判断不了.我的源码如下:
Private Sub Form_Load()
Web1.Navigate "http://www.youcall.com/zh/user/login"
While Web1.ReadyState <> 4
DoEvents
Wend
End Sub
Private Sub Command2_Click()
Set dblogin = OpenDatabase(App.Path + "\Db1.mdb", False, False, "MS Access;")
Set rs = dblogin.OpenRecordset("select * from user1")
Set vdoc = Web1.Document
For j = 1 To 100
username1 = "dm00" & j
vdoc.Forms(0).All("email").Value = username1
vdoc.Forms(0).All("password").Value = "789789"
vdoc.Forms(0).submit
While Web1.ReadyState <> 4
DoEvents
Wend
'问题就出在验证失败的代码, 因如果失败, 网址不会跳转,会提示一个错误. 但是"错误"提示还未出现,下面的代码就已经执行了,所以就判断不了.
怎样能让下面的代码发生在页面完全下载了之后执行?
'-----------------判断登陆失败代码, --------------
strhtml = ""
For Each i In vdoc.All
If TypeName(i) = "HTMLParaElement" Then
strhtml = i.innerText
' MsgBox STRHTML
mypos = InStr(1, strhtml, "错误", 1)
If mypos > 0 Then
unit = Mid(strhtml, mypos + 2, 4)
MsgBox unit
Label3.Caption = strhtml
Exit For
GoTo abc
End If
End If
Next i
'---------登陆成功,页面跳转---------------------------------
While Web1.LocationURL <> "http://www.youcall.com/zh/call/init"
DoEvents
Wend
While Web1.ReadyState <> 4
DoEvents
Wend
strhtml = ""
For Each i In vdoc.All
If TypeName(i) = "HTMLParaElement& 丢个板砖[0] 引用 举报 管理 TOP 回复次数:5
------解决方案--------------------
那就是判断当前地址没有变化而且网页上出现了错误提示.否则为成功登录
IF Web1.LocationURL = "http://www.youcall.com/zh/user/login" THEN
For Each i In vdoc.All
If TypeName(i) = "HTMLParaElement" Then
strhtml = i.innerText
mypos = InStr(1, strhtml, "错误", 1)
If mypos > 0 Then
Failure=1
Exit For
elseif Web1.LocationURL = "http://www.youcall.com/zh/call/init"
Failure=0
End If
End If
Next i
ENDIF
------解决方案--------------------
不用谢拉,大家相互学习了
问题解决就即时结贴吧.........