使用 vbscript 登录网页 [英] using vbscript to log into web page
问题描述
这段代码让我进入页面并填写用户名和密码字段,但在提交后,我从应用程序收到用户名和密码无效的响应.如果我不执行提交命令,而是让程序停在页面上,然后手动单击登录按钮,然后我就成功登录了.即使在表单上正确填写了 userid 和 paasword,它们似乎也没有正确传递到下一页.
This code gets me to the page and fills in the userid and password fields but after it does the submit I get a response from the application that the userid and password are not valid. If I don't execute the submit command but let the program stop at the page then manually click the login button then I successfully login. It appears eventhough the userid and paasword are being filled in correctly on the form, they are not getting passed through to the next page properly.
有什么想法吗?我是 VBsript 新手.
Any thoughts? I'm a VBsript newbie.
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "https://cpprod.stjohns.edu/cp/home/displaylogin"
Do
WScript.Sleep 500
loop While IE.ReadyState < 4 And IE.Busy
IE.Document.getElementByID("user").value = "testacct"
WScript.Echo IE.Document.getElementByID("user").value
IE.Document.getElementByID("pass").value = "testpw"
WScript.Echo IE.Document.getElementByID("pass").value
IE.Document.getElementByID("cplogin").submit
推荐答案
试试下面的方法,让我知道你的结果...
Give the below a try and let me know your results...
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
oIE.navigate WebPath
Do
WScript.Sleep 250
Loop While oIE.ReadyState < 4 And oIE.Busy
oIE.Document.All.Item("username").Value = sUser
WScript.Sleep 250
oIE.Document.All.Item("password").Value = sPass
WScript.Sleep 250
oIE.Document.All.Item("login").Click
这篇关于使用 vbscript 登录网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!