Foxtable(狐表)用户栏目专家坐堂 → [求助]自动登录网页的例子(内网怎么办)


  共有2333人关注过本帖树形打印复制链接

主题:[求助]自动登录网页的例子(内网怎么办)

帅哥哟,离线,有人找我吗?
天一生水
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
[求助]自动登录网页的例子(内网怎么办)  发帖心情 Post By:2018/8/14 15:36:00 [只看该作者]

用户名:jyhui

密码:305305

 

内网登录前网址:
http://xx.xx.100.221/logon.jsp

 

内网登录后网址:
http://xx.xx.100.205/jnzyweb/platformData/infoplat/pub/jnzyweo?flag=tz&userNameNew=jyhui&jsId=oxmeCRfDlYtqAlAlgQuewhf2hwhMGfxJb_2612/account/loginFun.d

 

其他的怎样改?

谢谢!
Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol

Dim Inputs = web.Document.GetElementById("login2").GetElementsByTagName("input")
For Each Input As object In Inputs
    If Input.id = "inputid" Then
        Input.SetAttribute("value", "jyhui")
    ElseIf input.id = "inputPassword"
        Input.SetAttribute("value", "305305")
    ElseIf Input.id = "btnQyyhdl" Then
        'Input.InvokeMember("click")
    End If
Next


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/8/14 15:44:00 [只看该作者]

浏览器那里按下F12,调出调试器,查看对应元素的结构,看id值是什么,或者特征是什么。

[此贴子已经被作者于2018/8/14 15:44:20编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
天一生水
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
  发帖心情 Post By:2018/8/14 16:11:00 [只看该作者]

没找到id:

 


<html>
<meta http-equiv="Content-Language" c>
<meta http-equiv="Content-Type" c>
<title>xxxxxxxxxxx门户平台</title>
<link href="js/css.css" rel="stylesheet" type="text/css">
<!--[if lte IE 6]>
<script type="text/javascript" src="js/IMG_PNG.js"></script>
<![endif]-->
<script language="JavaScript">
window.name="bjmath_logon";
ie4 = (document.all)?true:false;
ns4 = (document.layers)?true:false;
<!--
//页面装载时,进行焦点定位
//如果名字有内容同时选中了记住名字
//则焦点转移到密码框
function setFocus()
{
    if (document.logon.txt_username.value != ""){
        document.logon.txt_password.focus();
    }
    else{
        document.logon.txt_username.focus();
    }
    return;
}
//检测到回车就提交
function keyEnter(iKeyCode)
{
    //仅对于IE有效
    if (ie4){
        if(window.event.keyCode==13){
            checkuser();
        }
    }
}

//检查用户输入,无误后提交
function checkuser()
{
    if(document.logon.txt_username.value==""){
        alert("请输入用户名字!");
        document.logon.txt_username.focus();
        return;
    }
    if(document.logon.txt_password.value==""){
        alert("请输入用户密码!");
        document.logon.txt_password.focus();
        return;
    }
    if(document.getElementById("hasPwd").checked)
 {
     setLoginCookie();
 }else{
  deleteCookie();
 }
    document.logon.submit();
    document.logon.txt_password.value=""
  
}
//-->

</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
//让index始终在最上层,不嵌入到别的frame中
if(top!=window){
 top.location.href="logon.jsp";
}
function clearform(form){
 form.username.value="";
 form.password.value="";

}
 function SetHome() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(window.location.href);
    } else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {
                alert("该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config ,然后将项 signed.applets.codebase_principal_support 值该为true");
                history.go(-1);
            }
        }


        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', window.location.href);
    }
}

 
 //填充用户名称密码
 function getLoginCookie(){
   var username= getCookie("jnzyName") ;
   var password= getCookie("jnzyPwd") ;
   if(username!=null && username!="" && password!=null && password!=""){
     document.getElementById("txt_username").value=username;
     document.getElementById("txt_password").value=password;
     document.getElementById("hasPwd").checked = true;
    }
  }

  function getCookie(c_name)      //根据分隔符每个变量的值
  {
      if (document.cookie.length > 0) {
          c_start = document.cookie.indexOf(c_name + "=");
          if (c_start != -1) {
              c_start = c_start + c_name.length + 1;
              c_end = document.cookie.indexOf("@@@",c_start);
              if (c_end==-1)
                  c_end=document.cookie.length;
              return unescape(document.cookie.substring(c_start,c_end));
      }
    }
      return "";
  }
 
  function deleteCookie(){
  
   var exdate = new Date();
      exdate.setDate(exdate.getDate() - 1000);
      document.cookie = "jnzyName=^;expires=" + exdate.toGMTString();
  }
  function setLoginCookie(){
   
   var username=document.getElementById("txt_username").value;
   var password=document.getElementById("txt_password").value;
            setCookie("jnzyName", username, "jnzyPwd", password, 30);
  }
 
  function setCookie(c_name, n_value, p_name, p_value, expiredays)        //设置cookie
  {
      var exdate = new Date();
      exdate.setDate(exdate.getDate() + expiredays);
      document.cookie = c_name + "=" + escape(n_value) + "@@@" + p_name + "=" + escape(p_value) + ((expiredays == null) ? "" : "@@@;expires=" + exdate.toGMTString());
     
  }
  function topWin()
  {
   window.open("topwin.jsp","","width=1000px,height=600px");
  }
//-->
</SCRIPT>
<SCRIPT language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=foo>
document.forms[0].masc.value=unescape(MACAddr);
</SCRIPT>
<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
   if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
   {
    if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
    MACAddr = objObject.MACAddress;
    }
</SCRIPT>
<META c name=GENERATOR>
<style>
.bg{background:#3c86c7 url('../images/bg2012.jpg') repeat-x left top;}
</style>
</head>
<body topmargin="0" leftmargin="0" class="bg" >
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT></OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223></OBJECT>
<SCRIPT language=JScript>
   var service = locator.ConnectServer();
   var MACAddr ;
   service.Security_.ImpersonationLevel=3;
   service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</SCRIPT>
<div align="center">
 <table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
  <tr>
   <td align="center">
   <table border="0" width="1000" cellspacing="0" cellpadding="0">
    <tr>
     <td>
     <!--  <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="750" height="80">
      <param name="movie" value="images/top.swf">
      <param name="quality" value="High">
      <param name="wmode" value="transparent">
      <embed src="images/top.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="750" height="80"></object>-->
      <table>
      <tr><td valign="middle">
      <img src="tempimages/logo.gif" border="0"/ style="height: 50;"></td><td valign="middle"><img src="images/pingtai.png" border="0" align="middle"/>
      <!-- images/logo.png  -旧-->
      </td></tr>
      </table>
                    </td>
     <td valign="bottom">
     <table border="0" width="100%" cellpadding="0" cellspacing="0">
      <tr>
       <td align="right"><a href="http://10.28.100.221/" title='济南市中级人民法院审判管理平台' rel="sidebar">
       <img border="0" src="images/bn002.gif" width="79" height="22"></a></td>
       <td align="right" height="50">
                                                        <a href="javascript:SetHome();">
       <img border="0" src="images/bn001.gif" width="79" height="22"></a></td>
      </tr>
     </table>
     </td>
    </tr>
   </table>
   <table border="0" width="1000" cellspacing="0" cellpadding="0" background="images/c002.jpg">
    <tr>
     <td width="20">
     <img border="0" src="images/c001.jpg" width="20" height="400"></td>
     <td width="960">
     <table border="0" width="100%">
      <tr>
       <td width="20"></td>
       <td>
       <table border="0" bgcolor="#fffffff">
        <tr>
         <td>
         <!--
         <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj2" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="600" height="340">
                    <param name="movie" value="images/left.swf">
                    <param name="quality" value="High">
                                  <param name="wmode" value="transparent">
                    <embed src="images/left.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj2" width="600" height="340"></object> -->
                 
                    <iframe src="flash/index.jsp" frameborder="0" SCROLLING ="no" width=600px height=340px></iframe>
                   
                    </td>
        </tr>
       </table>
                                                        </td>
       <td>
       <table border="0" width="100%" cellpadding="0">
        <tr>
         <td><img border="0" src="images/login.gif" width="120" height="57"></td>
        </tr>
        <tr>
         <td height="20"></td>
        </tr>
       </table>
       <form name="logon" id="logon" action="enter.jsp" method="post">
       <input type="hidden" value="submit" name="hdn_submit_sign">
       <input value="no" type="hidden" name="masc" size="20" style="width:150px" read>
       <table border="0" width="100%" cellpadding="6">
        <tr>
         <td align="right">用户名</td>
         <td>
         <input type="text" size="31" style="border: 1px solid #C0C0C0" id=txt_username  name="txt_username"   ></td>
        </tr>
        <tr>
         <td align="right">密&nbsp; 码</td>
         <td>
         <input size="31" style="border: 1px solid #C0C0C0" id=txt_password type=password name=txt_password   ></td>
        </tr>
        <tr><td align="right"></td>
         <td>
         <input type="checkbox" name="hasPwd" id="hasPwd" value="1"/>记住密码
         </td>
        </tr>
        <tr>
         <td> </td>
         <td>
         <table border="0">
          <tr>
           <td style="cursor:pointer">
           <table border="0" width="60" cellspacing="0" cellpadding="0" background="images/anniu.gif" height="26">
            <tr>
             <td align="center"><b class="ald">登录</b></td>
            </tr>
           </table>

           </td>
           <td> </td>
           <td style="cursor:pointer"> <table border="0" width="60" cellspacing="0" cellpadding="0" background="images/anniu.gif" height="26">
            <tr>
             <td align="center"><b class="ald">退出</b></td>
            </tr>
           </table>
                                            </td>
           <td> </td>
           <td>
                                            </td>
          </tr>
         </table>
         </td>
        </tr>
        <tr><td></td><td align="right"><a href="/setup-jn.zip">控件下载</a></td></tr>
       </table></form>
                              </td>
       <td width="20"></td>
      </tr>
     </table>
     </td>
     <td width="20">
     <img border="0" src="images/c003.jpg" width="20" height="400"></td>
    </tr>
   </table>
   <table border="0" width="1000" cellspacing="0" cellpadding="0">
    <tr>
     <td height="20"></td>
    </tr>
    <tr>
     <td align="center" style="height:80px;line-height:35px"><span style="font-size:14px;font-weight:bold;color:#ffffff">————  版权所有:   ————</span>
                                        <br><!-- <span style="font-size:12px;font-weight:bold;color:#ffffff">技术支持:</span> -->
                                        </td>
    </tr>
   </table>
   </td>
  </tr>
  </table>
</div>

</body>
</html>

[此贴子已经被作者于2018/8/14 16:45:52编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/8/14 16:21:00 [只看该作者]

参考红色代码

 

         <td align="right">用户名</td>
         <td>
         <input type="text" size="31" style="border: 1px solid #C0C0C0" id=txt_username  name="txt_username"   ></td>
        </tr>
        <tr>
         <td align="right">密&nbsp; 码</td>
         <td>
         <input size="31" style="border: 1px solid #C0C0C0" id=txt_password type=password name=txt_password   ></td>
        </tr>
        <tr><td align="right"></td>
         <td>
         <input type="checkbox" name="hasPwd" id="hasPwd" value="1"/>记住密码


 回到顶部
帅哥哟,离线,有人找我吗?
天一生水
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
  发帖心情 Post By:2018/8/14 16:53:00 [只看该作者]

没登上...


Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol

Dim Inputs = web.Document.GetElementById("logon").GetElementsByTagName("txt_username")
For Each Input As object In Inputs
    If Input.id = "txt_username" Then
        Input.SetAttribute("value", "jyhui")
    ElseIf input.id = "txt_password"
        Input.SetAttribute("value", "305305")
    ElseIf Input.id = "hasPwd" Then
        'Input.InvokeMember("click")
    End If
Next


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/8/14 17:05:00 [只看该作者]

Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser1").basecontrol

Dim Inputs = web.Document.GetElementById("logon").GetElementsByTagName("input")
For Each Input As object In Inputs
msgbox(Input.id)
    If Input.id = "txt_username" Then
        Input.SetAttribute("value", "jyhui")
    ElseIf input.id = "txt_password"
        Input.SetAttribute("value", "305305")
    End If
Next

web.Document.InvokeScript("eval", new String() {"alert('abc');checkuser();alert('123')"})


 回到顶部
帅哥哟,离线,有人找我吗?
天一生水
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
  发帖心情 Post By:2018/8/15 11:46:00 [只看该作者]

没有填上登陆信息,依次弹出:

 

txt_username

txt_password

hasPwd

abc

123

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/8/15 12:06:00 [只看该作者]

1、代码没问题;信息绝对能填上。

 

2、如果无法提供实例,请联系客服远程测试。


 回到顶部