簡體   English   中英

如何使用VBS自動登錄網站

[英]How to automate a login to a website with VBS

在我的辦公室,有一個在線文檔查看系統,需要登錄。 我當時正在考慮使用VBS自動執行此操作,並得出以下結論:

 Call Main Function Main Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") IE.Visible = True IE.Navigate "***WEBSITE CENSORED***" Wait IE With IE.Document .getElementByID("username").value = "USERNAME" .getElementByID("password").value = "PASSWORD" .getElementByID("loginbtn")(0).Submit End With End Function Sub Wait(IE) Do WScript.Sleep 500 Loop While IE.ReadyState < 4 And IE.Busy End Sub 

從理論上講,這應該起作用( 認為),但事實並非如此。
我要去哪里錯了?

編輯:以下是我網站上的登錄表格。 出於安全原因,我已將其鏈接到example.com。

 <form id="login" action="http://example.com/login/index.php" method="post"> <div class="loginform"> <div class="form-label"><label for="username">Username</label></div> <div class="form-input"> <input name="username" id="username" type="text" size="15" value=""> </div> <div class="clearer"> <!-- --> </div> <div class="form-label"><label for="password">Password</label></div> <div class="form-input"> <input name="password" id="password" type="password" size="15" value=""> </div> </div> <div class="clearer"> <!-- --> </div> <div class="rememberpass"> <input name="rememberusername" id="rememberusername" type="checkbox" value="1"> <label for="rememberusername">Remember username</label> </div> <div class="clearer"> <!-- --> </div> <input id="loginbtn" type="submit" value="Log in"> <div class="forgetpass"><a href="forgot_password.php">Forgotten your username or password?</a></div> </form> 

感謝@SearchAndResQ的答案。

需要改變

.getElementByID(“ loginbtn”)(0)。提交

.getElementByID(“ loginbtn”)。click

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM