使用VB脚本自动登录网站 [英] Automatically logging in website using VB script
本文介绍了使用VB脚本自动登录网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试自动登录网站。我使用下面的代码
Dim objIE
Dim htmld
Set objIE = CreateObject(InternetExplorer.Application )
objIE.Visible = False
objIE.Navigatewebsite.com//website.com不是原始的
,而是objIE.Busy
WScript.Sleep 400
Wend
WScript.Sleep 500
objIE.Document.getElementById(login_id)。value =ss
文本框login_id的html代码为
< TABLE id = logintable cellSpacing = 0 GT;< TBODY>
< TR>
< TD>< / TD>< IMG src =/ nfusion / default / en_US / images / sign_in_flag.gif>< / TD>
< TD class = tdlabel>使用者ID:< / TD>
< TD>< INPUT id = login_id class = txt name = login_id>< / TD>< / TR>
< TR>
< TD>< / TD>
我得到的接口错误未知。我已经改变了安全性,login_id没有标签,所以我无法使用getElementByTag。
解决方案
我写了一个vbscript按照你的要求做,而且我一直都在使用它。它在IE中打开一个标签,然后登录,然后在应用程序的不同页面打开两个标签。
Error Resume NextECRecord =http://vm195/views/welcome.action
ECJobs =http://vm195/views/job/jobList.action?query.MaxResults = 500安培; allStates =假%2F&安培; query.ActiveState =真安培; query.ActiveState =假%2F&安培; query.PendingState =真安培; query.PendingState =假%2F&安培; query.CompletedState =假%2F&安培; query.FailedState =真安培; query.FailedState =假%2F&安培; query.CancelledState =真安培; query.CancelledState =假%2F&安培; query.HoldState =真安培; query.HoldState =假%2F&安培; query.jobTypes = -1&安培; allFreqs =真安培; allFreqs =假%2F&安培; query.DailyFrequency =真安培; query.DailyFrequency =假%2F&安培; query.IntervalFrequency =真安培; query.IntervalFrequency =假%2F&安培; query.SetDateFrequency =真安培; query.SetDateFrequency =假%2F&安培; query.SingleFrequency =真安培; query.SingleFrequency =假%2F&安培; query.patientId =安培; query.a ccessionNumber =& query.studyPk =& query.dateRange = -3& query.beginDate =& query.endDate =& Submit = Search& refreshRate = 120
ECConfig =http:// vm195 / views / org / organizationTree.action
设置oIE = CreateObject(InternetExplorer.Application)
oIE.Visible = True
'打开一个新窗口
oIE .Navigate2 ECRecord
Do(oIE.Busy)
WScript.Sleep 10
Loop
设置Helem = oIE.document。 getElementByID(username)
Helem.Value =tsu500'将其更改为您的
Set Helem = oIE.document.getElementByID(password)
Helem.Value =production '把它改成你的
oIE.Document.getElementsByName(submit_button)。Item(0).Click
'Set Helem = oIE.document.Forms(1)
'Helem.Submit
WScript.Sleep 500
Do(oIE.Busy)
WScript.Sleep 10
循环
'打开网址在新标签
oIE.Navigate2 ECJobs,2048
WScript.Sleep 100
oIE.Navigate2 ECConfig,2048
Set oIE = Nothing
I am trying to automate login process for a website. I used below code
Dim objIE
Dim htmld
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate "website.com" //website.com is example not the original
While objIE.Busy
WScript.Sleep 400
Wend
WScript.Sleep 500
objIE.Document.getElementById("login_id").value = "ss"
the html code for the textbox login_id is
<TABLE id=logintable cellSpacing=0><TBODY>
<TR>
<TD><IMG src="/nfusion/default/en_US/images/sign_in_flag.gif"></TD>
<TD class=tdlabel>User ID:</TD>
<TD><INPUT id=login_id class=txt name=login_id></TD></TR>
<TR>
<TD></TD>
I am getting error of the interface is unknown. I have changed the security and login_id does not have tag so i was not able to use getElementByTag.
解决方案
I wrote a vbscript to do just what you asked, and I use it all the time. It opens up one tab in IE, and logs in, then it opens two more tabs to different pages in our application.
On Error Resume Next
ECRecord = "http://vm195/views/welcome.action"
ECJobs = "http://vm195/views/job/jobList.action?query.MaxResults=500&allStates=false%2F&query.ActiveState=true&query.ActiveState=false%2F&query.PendingState=true&query.PendingState=false%2F&query.CompletedState=false%2F&query.FailedState=true&query.FailedState=false%2F&query.CancelledState=true&query.CancelledState=false%2F&query.HoldState=true&query.HoldState=false%2F&query.jobTypes=-1&allFreqs=true&allFreqs=false%2F&query.DailyFrequency=true&query.DailyFrequency=false%2F&query.IntervalFrequency=true&query.IntervalFrequency=false%2F&query.SetDateFrequency=true&query.SetDateFrequency=false%2F&query.SingleFrequency=true&query.SingleFrequency=false%2F&query.patientId=&query.accessionNumber=&query.studyPk=&query.dateRange=-3&query.beginDate=&query.endDate=&Submit=Search&refreshRate=120"
ECConfig = "http://vm195/views/org/organizationTree.action"
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
'open a new window
oIE.Navigate2 ECRecord
Do While (oIE.Busy)
WScript.Sleep 10
Loop
Set Helem = oIE.document.getElementByID("username")
Helem.Value = "tsu500" ' change this to yours
Set Helem = oIE.document.getElementByID("password")
Helem.Value = "production" ' change this to yours
oIE.Document.getElementsByName("submit_button").Item(0).Click
'Set Helem = oIE.document.Forms(1)
'Helem.Submit
WScript.Sleep 500
Do While (oIE.Busy)
WScript.Sleep 10
Loop
'open url In new tab
oIE.Navigate2 ECJobs, 2048
WScript.Sleep 100
oIE.Navigate2 ECConfig, 2048
Set oIE = Nothing
这篇关于使用VB脚本自动登录网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文