我正在尝试编写我的第一个网站登录脚本,但总是在第 9 行位置 9 处收到错误消息:
“需要对象:‘getElementByID(...)’800A01A8。
这是我的实际工作站点的代码:
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 = "[email protected] /cdn-cgi/l/email-protection"
.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
我怎样才能编写工作代码?
您的登录表单元素有name
而不是id
,所以你需要使用getElementsByName https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByName. Also, INPUT
元素没有Submit
方法、用途click
反而:
With IE.Document
.getElementsByName("tx_voputilities_pi1[email]")(0).value = "[email protected] /cdn-cgi/l/email-protection"
.getElementsByName("tx_voputilities_pi1[password]")(0).value = "mypassword"
.getElementsByName("tx_voputilities_pi1[sign_in]")(0).click
End With
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)