VBS网站登录脚本-“所需对象"错误 [英] VBS website login script - "Object required" error
本文介绍了VBS网站登录脚本-“所需对象"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写我的第一个网站登录脚本,但总是在第9行第9位出现错误:
I'm trying to write my first website login script but always getting an error in line 9 position 9 saying:
所需对象:'getElementByID(...)'800A01A8.
"Object Required: 'getElementByID(...)' 800A01A8.
这是我在实际工作站点上的代码:
Here's my code for the real working site:
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
如何编写工作代码?
推荐答案
Your login form elements have the name
rather than id
, so you need to use getElementsByName
. Also, INPUT
elements don't have the Submit
method, use click
instead:
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
这篇关于VBS网站登录脚本-“所需对象"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文