问题描述
我正在编写适用于不同网站的.vbs脚本文件,但我正在为我的大学网页编写自动登录脚本以进行网页登录。
I am writing .vbs script file which works for different sites, but I am writing auto login script for my university web page for internet page login.
所以我工作到填写用户名和密码,但我无法点击登录。
So I have working til where it fills out username and password but I can't get it to click login.
这是大学登录的链接。我不确定您是否可以从网络外访问它。
Here is link to university login. I am not sure that you can access it from out of network.
(注意编辑plz不要将其设为实时链接)
hxxps://wlc-airrowdy1.utsa.edu/fs/customwebauth/studentlogin.html
hxxps://wlc-airrowdy1.utsa.edu/fs/customwebauth/studentlogin.html
这是我的脚本代码。
WScript.Quit Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "https://wlc-airrowdy1.utsa.edu/fs/customwebauth/studentlogin.html"
Wait IE
WScript.Echo "This is WSH version", WScript.Version
With IE.Document
.getElementByID("username").value = "myuser"
.getElementByID("password").value = "mypass"
.getElementByID("top").submitAction
End With
End Function
Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub
Sub IE_OnQuit
On Error Resume Next
WScript.StdErr.WriteLine "IE closed before script finished."
WScript.Quit
End Sub
这是页面的源代码如果你无法访问上面的链接。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN" xml:lang="EN">
<head>
<title>UTSA: AIR Rowdy Wireless Network - The University of Texas at San Antonio</title>
<meta content=no-cache http-equiv=Cache-control />
<meta content=no-cache http-equiv=Pragma />
<meta content=-1 http-equiv=Expires />
<meta http-equiv="Content-Language" content="EN" />
<meta content="text/html; charset=iso-8859-1" http-equiv=Content-Type />
<meta name="author" content="UTSA IT: Christopher Chipps" />
<meta name="robots" content="none" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Description" content="The AIRowdy Guest wireless Internet access page." />
<meta name="Keywords" content="UTSA OIT, OIT, The Office of Information Technology, Department IT, Department Software, Help Desk" />
<meta name=GENERATOR content="MSHTML 8.00.7600.16535" />
<link rel="shortcut icon" href="http://www.utsa.edu/oit/favicon.ico" />
<link href="3col.css" type="text/css" rel="stylesheet" />
<SCRIPT language="javascript" type="text/javascript" src="./loginscript.js"></SCRIPT>
<SCRIPT language="javascript" type="text/javascript">
var url = "";
if(url != ""){
var link = document.location.href;
var searchString = "?redirect=";
var equalIndex = link.indexOf(searchString);
var redirectUrl = "";
if(equalIndex > 0) {
equalIndex += searchString.length;
redirectUrl += link.substring(equalIndex);
//attach the redirect url only if the ext web auth url doesn't contain it
searchString = "&redirect=";
equalIndex = url.indexOf(searchString);
if(equalIndex < 0){
url+= "&redirect=";
url+=redirectUrl;
}
}
window.location.href = url;
}
</SCRIPT>
</head>
<body>
<div class="h"><a href="#content">Skip to main content</a></div>
<table id="bodytable" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="banner1">
<img src="utsaicon2c.gif" alt="UTSA The University of Texas at San Antonio" /></td>
</tr>
<tr>
<td id="banner2">
<ul id="mainnav">
<li> </li>
</ul></td>
</tr>
<tr>
<!-- keep the td tags in one line or else you will have a gap in IE -->
<td id="leftcontent">
<h1><a name="content"></a>Welcome to AirRowdy</h1>
<FORM method=post action="/login.html">
<INPUT value=0 maxLength=15 size=16 type=hidden name=buttonClicked />
<INPUT value=0 maxLength=15 size=16 type=hidden name=err_flag />
<INPUT maxLength=31 size=32 type=hidden name=err_msg />
<INPUT value=0 maxLength=15 size=16 type=hidden name=info_flag />
<INPUT maxLength=31 size=32 type=hidden name=info_msg />
<INPUT maxLength=255 size=255 type=hidden name=redirect_url />
<table width="100%" border="0" cellpadding="0" cellspacing="10" class="border_padding">
<tr>
<td colspan="2" valign="top"><h2>Student Login</h2></td>
<td width="48%" rowspan="4" align="right" valign="top"><img src="AirRowdy1.gif" alt="Welcome to AirRowdy" width="244" height="155" border="0" /></td>
</tr><script language="javascript" type="text/javascript">getErrorMsgIfAny();</script>
<tr>
<td width="21%"><label for="username"><b>myUTSA ID (abc123)</b></label></td>
<td width="31%"><input type="text" maxlength=63 size=25 name=username /></td>
</tr>
<tr>
<td><label for="password"><b>Password</b></label></td>
<td><input onkeypress=submitOnEnter(event); maxlength=63 size=25 type=password name=password emweb_type="PASSWORD" autocomplete="off" /></td>
</tr>
<tr>
<td> </td>
<td><script language="javascript" type="text/javascript">getHtmlForButton("Submit","Login","button","submitAction()"); setDisabledBtn();</script></td>
</tr>
</table>
</FORM>
<p>AirRowdy is UTSA's wireless network. It is available from any building at UTSA (Main Campus, Downtown Campus and The Institute of Texan Cultures).</p>
<p>Log on to AirRowdy with
your UTSA ID (abc123) and password.</p>
<p>Logged-in users can
reach the Internet, access e-mail and print at one of UTSA's Print Spots on campus.</p>
<h3>Usage
Policy</h3>
<p>Use of the campus wireless network is governed by the <abbr title="The University of Texas at San Antonio" lang="en" xml:lang="en">UTSA</abbr> Information Resources Use and Security Policy (http://www.utsa.edu/hop/chapter8/8-12.cfm). By connecting to this network, you agree to abide by university policies regarding appropriate computer usage. </p>
<h3>About AirRowdy</h3>
<!-- <p>To ensure connectivity
you should purchase a wireless network card that is 802.11b or
802.11g (Wi-Fi) compliant. A web browser which supports SSL
and Javascript is also required. No configuration changes are
necessary once your wireless card is installed and functioning
correctly. All web traffic (HTTP, HTTPS, etc.) is allowed on the
wireless network.</p>-->
<!-- <p>You should connect to AIR Rowdy using a wireless network card that is 802.11b or
802.11g (Wi-Fi) compliant. A web browser which supports SSL
and Javascript is also required. No configuration changes are
necessary once your wireless card is installed and functioning
correctly. All web traffic (HTTP, HTTPS, etc.) is allowed on the
wireless network.</p>-->
<p>As a general rule,
traffic on wireless networks, including AirRowdy, is <i><b>not</b></i> encrypted. This means there is a risk of
having your session "sniffed" during transmission. If you plan
on entering sensitive information (passwords, credit card numbers)
on a website, ensure the site is SSL-encrypted - the URL
should start with http<strong><i>s</i></strong> (not http) and
you should see a "lock" icon in your browser's status
bar.</p>
<h3>AirRowdy
Help</h3>
<p><b>Students</b>: To activate
your UTSA ID, or if you are experiencing connection issues with
AirRowdy, please visit one of the Student Computing Services Labs
during regular hours for assistance.</p>
<p>- BB 2.01.20 (Main Campus)<br />
- FS 2.400 (Downtown
Campus)<br />
- Library JPL Information Commons </p> </td>
</tr>
<tr>
<td id="footer">
<div id="bottomNav"> <strong>© The University of Texas at San Antonio, One UTSA Circle, San Antonio, TX 78249-1644, (210) 458-4011</strong></div></td>
</tr>
<tr>
<td id="credit">Designed & Maintained by The Office of Information Technology — Last update:
<!-- #BeginDate format:Am1 -->August 12, 2010<!-- #EndDate -->-></td>
</tr>
</table>
</body>
</html>
推荐答案
我不确定表单元素是否有成员名为 submitAction
的方法。应该只是?
I'm not sure a form element has a member method called submitAction
. Should it be simply submit
?
我没有看到任何包含您要查找的ID的元素:username
,密码
或top
And I don't see any elements with the IDs you're looking for: "username"
, "password"
or "top"
With IE.Document
.getElementByID("username").value = "myuser"
.getElementByID("password").value = "mypass"
.getElementByID("top").submitAction
End With
I猜猜你正在寻找例如
I'm guessing you're looking for eg
<td width="31%"><input type="text" maxlength=63 size=25 name=username /></td>
您可以使用,返回元素数组
where you would use getElementsByName
, which returns an array of elements
dim elements: set elements = document.getElementsByName("username")
elements(0).Value = "username"
这篇关于VBS脚本getElementbyID错误(AutoLogin脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!