如何用VB制作自动登陆网站自动输入帐号密码
PrivateDeclareFunctiontimeGetTimeLib"winmm.dll"()AsLongPrivateSubForm_Load()WebBrowse...
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Sub Form_Load()
WebBrowser1.Navigate " http://reg4.163.com/CheckUser.jsp"
End SubPrivate Function M_Dom_oncontextmenu() As Boolean
M_Dom_oncontextmenu = False '禁用右键
End FunctionPrivate Sub Webbrowser1_DownloadComplete()
Set M_Dom = WebBrowser1.Document
End SubPrivate Sub Form_Resize()
If Me.WindowState <> 1 Then
WebBrowser1.Left = 10
WebBrowser1.Width = Me.Width - 120
WebBrowser1.Height = Me.Height - 800
End If
End Sub
Private Sub Command1_Click()
Dim Obj As ObjectSet Obj = WebBrowser1.Document
Obj.All.username.Value = Text1.Text
Obj.All.password.Value = Text2.Text
Obj.All.submit.Click
End Sub WebBrowser1.Navigate 参数我改了 (WebBrowser1.Navigate http://email.163.com/?from=newmsg#163)Obj.All.user.Value = Text1.Text 这段也改了username换成了user 能实现自动输入 但点击command1按钮时出问题 问题出在 Obj.All.submit.Click 无法实现登陆 展开
Private Sub Form_Load()
WebBrowser1.Navigate " http://reg4.163.com/CheckUser.jsp"
End SubPrivate Function M_Dom_oncontextmenu() As Boolean
M_Dom_oncontextmenu = False '禁用右键
End FunctionPrivate Sub Webbrowser1_DownloadComplete()
Set M_Dom = WebBrowser1.Document
End SubPrivate Sub Form_Resize()
If Me.WindowState <> 1 Then
WebBrowser1.Left = 10
WebBrowser1.Width = Me.Width - 120
WebBrowser1.Height = Me.Height - 800
End If
End Sub
Private Sub Command1_Click()
Dim Obj As ObjectSet Obj = WebBrowser1.Document
Obj.All.username.Value = Text1.Text
Obj.All.password.Value = Text2.Text
Obj.All.submit.Click
End Sub WebBrowser1.Navigate 参数我改了 (WebBrowser1.Navigate http://email.163.com/?from=newmsg#163)Obj.All.user.Value = Text1.Text 这段也改了username换成了user 能实现自动输入 但点击command1按钮时出问题 问题出在 Obj.All.submit.Click 无法实现登陆 展开
2个回答
2014-01-21
展开全部
'WEB网页QQ登陆的一部分,可以判断type这些进行确定'<div class="sign-input"><span class="title">帐 号:'</span>
'<span class="input"><input autocomplete="on" name="u" id="u" type="text" style="ime-'mode:disabled" class="input01" tabindex="1" value="QQ号码或Email帐号" onfocus="if (value =='QQ号'码或Email帐号'){value =''}" onblur="if (value ==''){value='QQ号码或Email帐号';}" /></span></div>
'<input type="submit" class="signin-btn" src=" http://imgcache.qq.com/ptlogin/v3/style/4/images/btn-signin.gif" value="" tabindex="5" id="login_button"/>
'代码: Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1 '检查所有标签
If UCase$(vDoc.All(i).tagName) = "INPUT" Then '如果找到INPUT标签
Set vTag = vDoc.All(i)
If vTag.Type = "text" And vTag.Name = "u" Then '找到网页代码里的type name
vTag.Value = "123"
End If
If vTag.Type = "submit" Then '1.因为就一个提交按钮,2.因为没有Name 所以不用 - -!
'vTag.Click
End If
End If
Next i
'<span class="input"><input autocomplete="on" name="u" id="u" type="text" style="ime-'mode:disabled" class="input01" tabindex="1" value="QQ号码或Email帐号" onfocus="if (value =='QQ号'码或Email帐号'){value =''}" onblur="if (value ==''){value='QQ号码或Email帐号';}" /></span></div>
'<input type="submit" class="signin-btn" src=" http://imgcache.qq.com/ptlogin/v3/style/4/images/btn-signin.gif" value="" tabindex="5" id="login_button"/>
'代码: Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1 '检查所有标签
If UCase$(vDoc.All(i).tagName) = "INPUT" Then '如果找到INPUT标签
Set vTag = vDoc.All(i)
If vTag.Type = "text" And vTag.Name = "u" Then '找到网页代码里的type name
vTag.Value = "123"
End If
If vTag.Type = "submit" Then '1.因为就一个提交按钮,2.因为没有Name 所以不用 - -!
'vTag.Click
End If
End If
Next i
2014-01-21
展开全部
不一定是all,复杂的网页有可能是body,form或者其他自定义的名字,要会分析网页.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询