0
我正在編寫適用於不同網站的.vbs腳本文件,但我正在爲我的大學網頁編寫自動登錄腳本以進行互聯網頁面登錄。VBS腳本getElementbyID錯誤(自動登錄腳本)
所以我一直在努力,直到它填寫用戶名和密碼,但我不能得到它點擊登錄。
這是鏈接到大學登錄。我不確定您是否可以通過網絡訪問它。
(編者注PLZ不要讓它活鏈接)
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>
謝謝你解釋,因爲我現在不在學校,所以現在我不能嘗試,但是因爲你的代碼中沒有使用elementbyId,因爲我們沒有ID?但我發佈了'.getElementByID(「username」)。value =「myuser」'這是張貼用戶名和密碼的代碼。 – Mowgli