用于自动的VB脚本登录到网站时出错

时间:2016-05-04 06:41:58

标签: vbscript

我使用下面的VB脚本自动登录到网站。它输入了用户名,但没有输入密码,并且提供了“不支持此属性或方法”的错误。 。我没有在VB脚本中工作过,所以不确定为什么会出现这个错误。

    On Error Resume Next
    Const PAGE_LOADED = 4
    Set objIE = CreateObject("InternetExplorer.Application")
    Call objIE.Navigate("http://www.gmail.com")
    objIE.Visible = True
    Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop
    objIE.Document.all.username.Value = "username"
    objIE.Document.all.Passwd.Value = "password"
    If Err.Number <> 0 Then
    msgbox "Error: " & err.Description
    End If
    Call objIE.Document.all.login_form.submit
    Set objIE = Nothing

1 个答案:

答案 0 :(得分:0)

尝试使用此代码可以解决问题,因为gmail已经更改了源代码!

Dim IE
Set IE = Wscript.CreateObject("InternetExplorer.Application")
IE.Visible = 1 
IE.navigate("https://accounts.google.com/ServiceLogin?service=ig&passive=true&continue=http://www.google.com/ig%3Fhl%3Den&followup=http://www.google.com/ig%3Fhl%3Den&cd=US&hl=en&nui=1&ltmpl=default")
Do While (IE.Busy)
    WScript.Sleep 10
Loop
Set Helem = IE.document.getElementById("Email")
Helem.Value = "Your Login goes here" 'Change to your Gmail login 
Set Helem = IE.document.Forms(0)
Helem.Submit 
Do While (IE.Busy)
    WScript.Sleep 10
Loop
wscript.sleep 2000
Set Helem = IE.document.getElementById("Passwd") 
Helem.Value = "Your Password goes here" 'Change to your Gmail password
Set Helem = IE.document.Forms(0)
Helem.Submit