找回密码
 加入
搜索
查看: 4503|回复: 5

[IE类操作] 如何获取ASPX网页上的信息

[复制链接]
发表于 2011-2-19 23:28:52 | 显示全部楼层 |阅读模式
本帖最后由 ken0137 于 2011-2-19 23:30 编辑

各位好
如题所述,
1.我想要获取一个aspx网页上的信息或者点击某个按钮,要如何操作
2.对于点击aspx网页中一个按钮,然后跳出来的一个新的窗口,如何去的这个窗口的中的信息,例如里面的下拉列表中的信息?

aspx网页为多frame组成的,所以用_IEDocReadHTML函数读取的源文件是读不到真正的元素的
</title>
    <style type="text/css">
    <!--
    body {
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
    }
    -->
    </style>
</head>
<frameset rows="100,*,25" cols="*" frameborder="no" border="0" framespacing="0">
    <frame id="Header" name="Header" src='Header.aspx?usbguid=&moduleId=01&menuId='
        scrolling="No" noresize="noresize" />
    <frameset id="Main" rows="*" cols="201,*" frameborder="no" border="0" framespacing="0">
        <frame id="Left" name="Left" scrolling="No" noresize="noresize" title="leftFrame" src='Left.aspx?moduleId=01&menuId=' />        
        <frame id="Right" name="Right" src="ContentPage.aspx" />
    </frameset>
    <frame id="Bottom" name="Bottom" src="Bottom.aspx" scrolling="No" noresize="noresize" />
</frameset>
</html>
发表于 2011-2-20 12:29:33 | 显示全部楼层
我也想知道,帮顶........
 楼主| 发表于 2011-2-20 14:21:59 | 显示全部楼层
谢谢帮顶~~
 楼主| 发表于 2011-2-22 09:13:13 | 显示全部楼层
是不是无法对ASPX类型的网页进行操作的啊?
发表于 2011-2-23 00:59:14 | 显示全部楼层
_IEFrameGetObjByName
_IEFrameGetCollection
得到Frame对象后再操作
 楼主| 发表于 2011-2-23 14:00:56 | 显示全部楼层
本帖最后由 ken0137 于 2011-2-23 14:10 编辑

是这样的,一开始是个登陆界面,登陆后跳转到另外一个页面
是不是先要_IEAttach 这个跳转的页面,然后使用_IEFrameGetObjByName得到所有的feame
是不是这样,
$UserName='xxx'
$Pwd='ppp'
$oIE = _IECreate("http://www.com")
$oForm=_IEFormGetObjByName($oIE,'form1')
$TxtUserName= _IEFormElementGetObjByName ($oForm, "TxtUserName")
_IEFormElementSetValue($TxtUserName,$UserName)
$TxtPassword= _IEFormElementGetObjByName ($oForm, "txtPassword")
_IEFormElementSetValue($TxtPassword,$Pwd)
$oSubmit= _IEGetObjByName ($oForm, "BtnLogon")
_IEAction($oSubmit,"click")
这样就登陆了,然后在同一页面中等待跳转
sleep(10000)
$oIE=_IEAttach("xxxxx有限公司ERP","title")
$oFrameMain = _IEFrameGetObjByName($oIE, "Header")
下面的代码可以取得input的属性
$xs = _IETagNameGetCollection ($oFrameMain, "input")
For $x In $xs
   MsgBox(0, "Form Input Type", "Form: " & $x.form.name & " Type: " & $x.id)
Next
但是若是改成其他元素的对象,就不能取到值了,例如
$xs = _IETagNameGetCollection ($oFrameMain, "input")
变为
$xs = _IETagNameGetCollection ($oFrameMain, "div")
我想点击head.aspx中<li  这里的
<li style="vertical-align:middle"><a   style="zoom:1;vertical-align:baseline;" id='module_02' href="#" onclick="ClickMenu('02')">
                            业务中心/ My Job
的按钮,但是不知道怎么做,赐教!

下面是head.aspx的代码
<!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">
<head><title>
        无标题页
</title><link rel="stylesheet" type="text/css" href="App_Themes/Styles/topFrame.css" />
    <style type="text/css">
    <!--
    body {
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
    }
    -->
    </style>

    <script type="text/javascript" language="javascript">
    var isInit = false;
    var selectedModuleId = '01';
    var selectedMenuId = '';
    var paramString = '';
    
    function ClickMenu(moduleId)
    {
        ShowStyle(moduleId);
        
        ClickMenu2(moduleId);
    }
    function ClickMenu2(moduleId)
    {
        if(top.Left.document.readyState != 'complete')
        {
            setTimeout('ClickMenu2('+ moduleId + ');', 100);
            return;
        }
        
        var menu = top.Left.document.getElementById('menu_' + moduleId);
        var menu2 = top.Left.document.getElementById('menu2_' + moduleId);
        var hdn = top.Left.document.getElementById('hdnIsSetHeaderStyle');
        
       
        if(menu != null && menu2 != null && hdn != null)
        {
            hdn.value = '1';
            if(menu.style.display == 'none')
            {
                menu2.click();   
            }
            else
            {
                menu.click();
            }
        }
    }
    function Init()
    {
        var tempModule = document.getElementById('module_' + selectedModuleId);       
        if(tempModule != null)
        {            
            isInit = true;
            tempModule.click();
            isInit = false;
        }
    }
    function ShowStyle(newModuleId)
    {
        var oldId = 'module_' + selectedModuleId;
        var newId = 'module_' + newModuleId;
        var oldModule = document.getElementById(oldId);
        var newModule = document.getElementById(newId);
        
        if(oldModule != null)
        {
            oldModule.className = '';
        }
        if(newModule != null)
        {
            newModule.className = 'selected';
        }          
        
        selectedModuleId = newModuleId;
    }
    function ClickHomePage()
    {
        top.document.getElementById('Right').src = 'Index.aspx?rdm=' + Math.random();;
    }
    function Logout()
    {
        top.window.location = 'Logon.aspx?usbguid=' + document.getElementById('hflUsbGuid').value;
    }
    //left.aspx用来设置header.aspx中选中模块的样式
    function SetModuleStyle()
    {
        var hdn = document.getElementById('hdnNewModuleId');
        if(hdn != null)
        {
            if(hdn.value != -1)
            {
                ShowStyle(hdn.value);
            }
        }
    }
    function ShowMustKnow()
    {
        window.showModalDialog('html/MustKnow.htm?random=' + Math.random(),document,'dialogHeight: 630px; dialogWidth: 750px;edge: Raised; center: Yes; help: No; resizable: Yes; status: No;scrollbars:auto');
    }
    </script>

</head>
<body onload="Init();">
    <form name="form1" method="post" action="Header.aspx?usbguid=&moduleId=01&menuId=" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTc2Njc2NjczMg9kFgICAw9kFgJmDxYCHgtfIUl0ZW1Db3VudAIDFgZmD2QWAmYPFQMJbW9kdWxlXzAxD0NsaWNrTWVudSgnMDEnKRzmtojmga/kuK3lv4MvIE1lc3NhZ2UgQ2VudGVyZAIBD2QWAmYPFQMJbW9kdWxlXzAyD0NsaWNrTWVudSgnMDInKRTkuJrliqHkuK3lv4MvIE15IEpvYmQCAg9kFgJmDxUDCW1vZHVsZV8wMw9DbGlja01lbnUoJzAzJykU572R5LiK5ZWG5Z+OLyBFLVNob3BkZGiGsXVp5njaAgfZneKE6GOdQ3Y9" />
</div>

        <div id="HBG">
            <div id="logo">
            </div>
            <div id="welcome">
                <p>
                    欢迎你,张婕</p>
                <p>
                    <a href="#" onclick="window.showModalDialog('./UC/ORG/PassWord.aspx',window,'dialogHeight:225px; dialogWidth:330px; dialogTop:150px; dialogLeft:300px; edge:Raised; center:Yes; help:No; resizable:Yes; status:Yes;');">修改密码</a>  |  <a href="#" onclick="Logout();">退出</a></p>
            </div>
        </div>
        <div id="mainNav">
            <ul>                
                
                        <li style="vertical-align:middle"><a   style="zoom:1;vertical-align:baseline;" id='module_01' href="#" onclick="ClickMenu('01')">
                            消息中心/ Message Center
                        </a>
                            <img src="App_Themes/Images/line.gif" width="2" height="16" />
                            </li>
                    
                        <li style="vertical-align:middle"><a   style="zoom:1;vertical-align:baseline;" id='module_02' href="#" onclick="ClickMenu('02')">
                            业务中心/ My Job
                        </a>
                            <img src="App_Themes/Images/line.gif" width="2" height="16" />
                            </li>
                    
                        <li style="vertical-align:middle"><a   style="zoom:1;vertical-align:baseline;" id='module_03' href="#" onclick="ClickMenu('03')">
                            网上商城/ E-Shop
                        </a>
                            <img src="App_Themes/Images/line.gif" width="2" height="16" />
                            </li>
                    
            </ul>
        </div>
        <input type="hidden" name="hflUsbGuid" id="hflUsbGuid" />
        <input type="hidden" id="hdnNewModuleId" value="-1" />
        <input type="button" id="btnShowNewModuleStyle" onclick="SetModuleStyle();" style="display:none;" />
    </form>
</body>
</html>
接下来想要点击“业务中心”这个按钮,要如何才能取得呢?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 13:43 , Processed in 0.084765 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表