0

我正在编写适用于不同站点的 .vbs 脚本文件,但我正在为我的大学网页编写用于互联网页面登录的自动登录脚本。

所以我一直在工作,直到它填写用户名和密码,但我无法点击登录。

这是大学登录的链接。我不确定您是否可以从网络外访问它。

(请注意编辑请不要将其设为实时链接)

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>&nbsp;</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>&nbsp;</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. &nbsp;</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.&nbsp; A web browser which supports SSL 
                    and Javascript is also required.&nbsp; 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.&nbsp; A web browser which supports SSL 
                    and Javascript is also required.&nbsp; 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 &quot;sniffed&quot; during transmission.&nbsp; 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)&nbsp; and 
                    you should see a &quot;lock&quot; 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>&copy; 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 &amp; Maintained by The Office of Information Technology &#8212; Last update:
                   <!-- #BeginDate format:Am1 -->August 12, 2010<!-- #EndDate -->-></td>
                </tr>
        </table>
</body>
</html>
4

1 回答 1

0

我不确定表单元素是否有一个名为submitAction. 是不是应该简单submit吗?

而且我没有看到任何具有您要查找的 ID 的元素:"username""password""top"

With IE.Document
    .getElementByID("username").value = "myuser"
    .getElementByID("password").value = "mypass"
    .getElementByID("top").submitAction
End With

我猜你正在寻找例如

<td width="31%"><input type="text" maxlength=63 size=25 name=username /></td>

您将使用的位置getElementsByName,它返回一个元素数组

dim elements: set elements = document.getElementsByName("username")
elements(0).Value = "username"
于 2013-01-15T08:50:00.737 回答