Login VBS网站登录脚本-“;“所需对象”;错误
我正试图编写我的第一个网站登录脚本,但在第9行的第9个位置总是出现一个错误,上面写着: “需要对象:'getElementByID(…)'800A01A8。” 以下是我的真实工作现场代码:Login VBS网站登录脚本-“;“所需对象”;错误,login,vbscript,Login,Vbscript,我正试图编写我的第一个网站登录脚本,但在第9行的第9个位置总是出现一个错误,上面写着: “需要对象:'getElementByID(…)'800A01A8。” 以下是我的真实工作现场代码: Call Main Function Main Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") IE.Visible = True IE.Navigate "https://www.valuedopinions.com
Call Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "https://www.valuedopinions.com/eng/signin"
Wait IE
With IE.Document
.getElementByID("tx_voputilities_pi1[email]").value = "my@email.com"
.getElementByID("tx_voputilities_pi1[password]").value = "mypassword"
.getElementByID("tx_voputilities_pi1[sign_in]")(0).Submit
End With
End Function
Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub
callmain
主要功能
设置IE=WScript.CreateObject(“InternetExplorer.Application”、“IE”)
可见=真实
即“导航”https://www.valuedopinions.com/eng/signin"
等等
用IE文件
.getElementByID(“tx\u voputilities\u pi1[电子邮件]”)。值=“my@email.com"
.getElementByID(“tx\u voputilities\u pi1[密码]”)。value=“mypassword”
.getElementByID(“tx\u voputilities\u pi1[登录]”)(0)。提交
以
端函数
分段等待(IE)
做
WScript.Sleep 500
当IE.ReadyState<4且IE.Busy时循环
端接头
如何编写工作代码?您的登录表单元素具有
名称而不是id
,因此您需要使用。此外,输入
元素没有提交
方法,请改为使用单击
:
With IE.Document
.getElementsByName("tx_voputilities_pi1[email]")(0).value = "my@email.com"
.getElementsByName("tx_voputilities_pi1[password]")(0).value = "mypassword"
.getElementsByName("tx_voputilities_pi1[sign_in]")(0).click
End With
您的登录表单元素具有名称
而不是id
,因此您需要使用。此外,输入
元素没有提交
方法,请改用单击
:
With IE.Document
.getElementsByName("tx_voputilities_pi1[email]")(0).value = "my@email.com"
.getElementsByName("tx_voputilities_pi1[password]")(0).value = "mypassword"
.getElementsByName("tx_voputilities_pi1[sign_in]")(0).click
End With
作为旁注:IE.ReadyState<4和IE.Busy
是冗余的。这两个条件中的任何一个都可以满足。作为旁注:IE.ReadyState<4和IE.Busy
是冗余的。这两个条件中的任何一个都可以满足。