我如何刮去ASP.NET网站信息正在使用分页和JavaScript链接时? [英] How do I scrape information off ASP.NET websites when paging and JavaScript links are being used?

查看:349
本文介绍了我如何刮去ASP.NET网站信息正在使用分页和JavaScript链接时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑这应该是最新的一个工作人员名单,但它不匹配的Intranet这是写在ASP.NET人物查找。

由于信息是敏感的,我无法访问人民搜索是用这样的数据库中,我可以在信息获取的唯一途径是通过刮起始于顶部的高层结构,然后经历每层反过来。

每个人都有,然后形成了网址 HTTP一个职工人数://intranet/peoplefinder/index.aspx SRN = ABC1234 ,然后所有谁举报的人他们是在格式列出underneth <一个ID =gvEmployees_ctl03_lnkFullName的href =的Index.aspx SRN = ABC4321?TARGET =_自我> ,其中每个URL指示工作人员数量,并提供了一​​个链接到他们的队伍。

麻烦出现时,寻呼是在GridView实现与URL,如&LT的球队都大; A HREF =JavaScript的:__ doPostBack('gvEmployees','页面$ 2')&GT 2 LT; / A>

我怎么会凑这个页面,捕捉谁上,然后遍历每个reportee在GridView的所有页面的人汇报,并做同样的过程,直到整个名单是完整的人沿着SRN和其他细节?

结果示例HTML

 <!DOCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/ XHTML1-transitional.dtd>< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
< HEAD><标题>
    寻人:名字姓
< /标题><链接rel =样式的href =/路径/要/ style.css中类型=文/ CSS/><链接rel =样式的href =/路径/到/anotherStyle.css类型​​=文/ CSS/>
    <脚本类型=文/ JavaScript的SRC =/路径/要/ peoplefinder.js>< / SCRIPT>
< /头>
<身体GT;
    <表格名称=Form1的方法=邮报行动=/路径/要/的Index.aspxID =form1的>
< D​​IV>
<输入类型=隐藏的名字=__ EVENTTARGETID =__ EVENTTARGETVALUE =/>
<输入类型=隐藏的名字=__ EVENTARGUMENTID =__ EVENTARGUMENTVALUE =/>
<输入类型=隐藏的名字=__ VIEWSTATEID =__ VIEWSTATEVALUE =###的ViewState ###/>
< / DIV><脚本类型=文/ JavaScript的>
<! -
VAR theForm = document.forms ['form1的'];
如果(!theForm){
    theForm = document.form1;
}
功能__doPostBack(的eventTarget,eventArgument){
    如果(!theForm.onsubmit ||(theForm.onsubmit()!= FALSE)){
        theForm .__ EVENTTARGET.value =的eventTarget;
        theForm .__ EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// - >
< / SCRIPT>
<脚本的src =/路径/要/ WebResource.axd的D = AueXWrgAf8xSxMTAt1Q4AA2&放大器;放大器; T = 633311832634916698类型=文/ JavaScript的>< / SCRIPT>        < D​​IV CLASS =HP3CHeader>
            < D​​IV ID =LWHPBanner>
                < H1><跨度ID =lblName>名姓< / SPAN>< / H1>
            < / DIV>
        < / DIV>        < D​​IV ID ='CPMain'>
            < D​​IV ID =mainBox>            < D​​IV ID =pnlEmployeeDetails>                < D​​IV ID ='basicData'>
                    < IMG ID =imgPhoto级=照片SRC =/路径/要/ photo.jpg的风格=高度:69px;宽度:69px;边框宽度:0像素; />
                    <跨度ID =lblBusinessUnit>业务单位和LT; / SPAN>
                    <跨度ID =lblCostCentreName>成本中心< / SPAN>
                    <跨度ID =lblLocation>位置和LT; / SPAN>                    < A HREF ='/路径/要/ checkcontactdetails.htm'的目标='_空白的onclick =回归OpenCheckContactDetails();' >了解如何改变您的详细信息/图片< / A>
                    < D​​IV ID =经理>
        <强>提交:< / STRONG><一个ID =hlManager的href =?/路径/要/的Index.aspx SRN = ABC1234>名姓< / A>
    < / DIV>
                < / DIV>                < D​​IV ID ='联络资料'>                    < D​​IV ID =pnlSrn>
        <强>员工人数:< / STRONG> &所述;跨度的id =lblSrn> ABC1234&下; /跨度>
    < / DIV>
                    < D​​IV ID =pnlEmailAddress>
        <强>邮箱地址:< / STRONG> <跨度ID =lblEmailAddress>电子邮件和LT; / SPAN>
    < / DIV>
                    < D​​IV的风格=明确:既>< / DIV>
                < / DIV>< / DIV>            < D​​IV ID =pnlGrid>                < H3><跨度ID =lblGridTitle>名称的团队< / SPAN>< / H3 GT&;
            < D​​IV>
        <表类=下属CELLSPACING =0的cellpadding =2规则=COLSBORDER =1ID =gvEmployees的风格=BORDER-风格:无;边界崩溃:崩溃;&GT ;
            < TR风格=颜色:黑色;背景颜色:#EFF3FB;边框样式:无;字体重量:大胆;>
                百分位范围=山口>< A HREF =JavaScript的:__ doPostBack('gvEmployees','排序$ SRN')的风格=颜色:黑色;> SRN< / A>< /第i ;百分位范围=山口>< A HREF =JavaScript的:__ doPostBack('gvEmployees','排序$全名')的风格=颜色:黑色;>全名< / A>< /第i个百分位范围=山口>< A HREF =JavaScript的:__ doPostBack('gvEmployees','排序$ RACFID')的风格=颜色:黑色;> RACFID< / A>&LT ; /第i
            < / TR>< TR类=报告的风格=背景颜色:白色,边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <?的Index.aspx SRN = 1K5932一个ID =gvEmployees_ctl02_lnkFullName的href =目标=_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景色:#EFF3FB;边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl03_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景颜色:白色,边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl04_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景色:#EFF3FB;边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl05_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景颜色:白色,边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl06_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景色:#EFF3FB;边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl07_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景颜色:白色,边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl08_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景色:#EFF3FB;边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl09_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景颜色:白色,边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl10_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=报告的风格=背景色:#EFF3FB;边框样式:无;>
                < TD风格=宽度:70像素;>&ABC1234 LT; / TD>< TD>
                            <一个ID =gvEmployees_ctl11_lnkFullName的href =/路径/要/的Index.aspx SRN = ABC1234?TARGET =_自我>名姓< / A>
                        < / TD>< TD> ABCD< / TD>
            < / TR>< TR类=PagerStyle的风格=COLOR:#000039; BORDER-风格:无;>
                < TD合并单元格=3><表格边框=0>
                    &所述; TR>
                        < TD><跨度大于1< / SPAN>< / TD>< TD>< A HREF =JavaScript的:__ doPostBack('gvEmployees','页面$ 2')的风格=COLOR:#000039; →2&下; / A>&下; / TD>
                    < / TR>
                < /表>< / TD>
            < / TR>
        < /表>
    < / DIV>< / DIV>
            < / DIV>            < D​​IV ID =搜索框>
                <强>搜索寻人:LT; / STRONG>
                < BR />< BR />
                <跨度>用名字:LT; / SPAN>< BR />
                <跨度><输入名称=txtFirstname类型=文本ID =txtFirstname/>< / SPAN>< BR />
                <跨度>姓氏:其中; / SPAN>< BR />
                <跨度><输入名称=txtSurname类型=文本ID =txtSurname/>< / SPAN>< BR />
                &所述;跨度> RACFID:或其可/跨度>&所述峰; br />
                <跨度><输入名称=txtRacfid类型=文本ID =txtRacfid/>< / SPAN>< BR />
                <跨度>员工人数:< / SPAN>< BR />
                <跨度><输入名称=txtSrn类型=文本ID =txtSrn/>< / SPAN>< BR />
                < D​​IV CLASS =searchBoxItem的风格=文本对齐:中心;宽度:100%><输入类型=提交名称=btnFind值=搜索的onclick =JavaScript的:WebForm_DoPostBackWithOptions(新WebForm_PostBackOptions(安培; QUOT; btnFind&安培; QUOT;,&安培; QUOT;&安培; QUOT ;,假的,和放大器; QUOT;&安培; QUOT;,&安培; QUOT;的Index.aspx和放大器; QUOT ;,假的,假的))ID = btnFind称号=搜索员工成员级=button风格=BORDER-风格:开端; />< / DIV>< BR />
                < D​​IV>寻人搜索英国唯一的工作人员与LT; / DIV>
               <! - < D​​IV><一类=execBoardLink的href =?/路径/要/的Index.aspx SRN = ABC1234>显示执行委员会和LT; / A>< / DIV> - >
                < D​​IV的风格=的margin-top:为5px;>< A HREF =/路径/要/电话簿目标=电话簿的onclick =返回OpenPhonebook();'标题=打开电话簿中的新窗口>开放式电话簿和LT; / A>< / DIV>
            < / DIV>
        < / DIV>        < D​​IV CLASS =contentFooter的风格=文本对齐:中心;>
            <表格的宽度=100%的cellpadding =0CELLSPACING =0边界=0摘要=导航布局表>
                &所述; TR>
                    < TD align =left><跨度类=linkArrow>&放大器; LT;< / SPAN> < A HREF =JavaScript的:history.back();>返回< / A>< / TD>
                    < TD ALIGN =中心>< / TD>
                    &所述; TD对齐=右>&下;跨度类=linkArrow> ^&下; /跨度>&下; A HREF =#顶>顶部和下; / A>&下; / TD>
                < / TR>
            < /表>
        < / DIV>< D​​IV>    <输入类型=隐藏的名字=__ preVIOUSPAGEID =__ preVIOUSPAGEVALUE =vy066Txz34y1E515UsTSTDabHKEmdBRCsq7xM0lpJls1/>
    <输入类型=隐藏的名字=__ EVENTVALIDATIONID =__ EVENTVALIDATION value=\"/wEWCgKM3uTTAgLP/83pDwLfwaTTAQKNguzjCAKt98LeCwLZh62pDwKKqdGpBwLd2q7jAwKa+5aMBAL5zb65C42zY4GBEUKujhjtZ/hZ8sLESfiF\" />
< / DIV>< /表及GT;
< /身体GT;
< / HTML>


解决方案

您可以变量发布到HTML页面要经过分页。

 字符串lcUrl =htt​​p://www.mysite.com/page.aspx;HttpWebRequest的loHttp =   (HttpWebRequest的)WebRequest.Create(lcUrl);
// ***发送任何POST数据串lcPostData =   gvEmployees =+ HttpUtility.UrlEn code(页面$ 2);loHttp.Method =POST;字节[] = lbPostBuffer System.Text。                       Encoding.GetEncoding(1252).GetBytes(lcPostData);loHttp.ContentLength = lbPostBuffer.Length;流loPostData = loHttp.GetRequestStream();loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);loPostData.Close();HttpWebResponse loWebResponse =(HttpWebResponse)loHttp.GetResponse();编码ENC = System.Text.Encoding.GetEncoding(1252);StreamReader的loResponseStream =   新的StreamReader(loWebResponse.GetResponseStream(),ENC);字符串lcHtml = loResponseStream.ReadToEnd();loWebResponse.Close();loResponseStream.Close();

然后分析出你从字符串需要的数据。

- 编辑 -

下面是我想尝试,所有的POST数据的发送(类似的东西):

 字符串lcPostData =       __EVENTTARGET+ HttpUtility.UrlEn code(gvEmployees); &安培;
__EVENTARGUMENT+ HttpUtility.UrlEn code(页%242); &安培;
__VIEWSTATE+ HttpUtility.UrlEn code(< _Viewstate&GT的价值;);

I have been given a staff list which is supposed to be up to date but it doesn't match an intranet People Finder which is written in ASP.NET.

As the information is sensitive I am not able to access the database the People Finder is using so the only way I can get at the information is by scraping the structure starting at the top brass at the top and then going through each tier in turn.

Each person has a Staff number which then forms the URL http://intranet/peoplefinder/index.aspx?srn=ABC1234 and then all the people who report to them are listed underneth in the format <a id="gvEmployees_ctl03_lnkFullName" href="index.aspx?srn=ABC4321" target="_self"> where each URL indicates the Staff number and provides a link to their team.

The trouble arises when the teams are big as paging is implemented in the GridView with an URL such as <a href="javascript:__doPostBack('gvEmployees','Page$2')">2</a>.

How would I scrape this page, capture the SRN and other details along with the people who report to the person on all pages of the GridView then loop through each reportee and do the same process until the whole list is complete?

Example HTML of result

<!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>
    People Finder: Name Surname
</title><link rel="stylesheet" href="/path/to/style.css" type="text/css" /><link rel="stylesheet" href="/path/to/anotherStyle.css" type="text/css" />
    <script type="text/javascript" src="/path/to/peoplefinder.js"></script>
</head>
<body>
    <form name="form1" method="post" action="/path/to/index.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="### ViewState ###" />
</div>

<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</script>


<script src="/path/to/WebResource.axd?d=AueXWrgAf8xSxMTAt1Q4AA2&amp;t=633311832634916698" type="text/javascript"></script>

        <div class="HP3CHeader">
            <div id="LWHPBanner">
                <h1><span id="lblName">Name Surname</span></h1>
            </div>
        </div>

        <div id='CPMain'>
            <div id="mainBox">

            <div id="pnlEmployeeDetails">

                <div id='basicData'>
                    <img id="imgPhoto" class="photo" src="/path/to/photo.jpg" style="height:69px;width:69px;border-width:0px;" />
                    <span id="lblBusinessUnit">Business Unit</span>
                    <span id="lblCostCentreName">Cost Centre</span>
                    <span id="lblLocation">Location</span>

                    <a href='/path/to/checkcontactdetails.htm' target='_blank' onclick='return OpenCheckContactDetails();' >Find out how to change your details/photo.</a>
                    <div id="manager">
        <strong>Reports to: </strong><a id="hlManager" href="/path/to/index.aspx?srn=ABC1234">Name Surname</a>
    </div>
                </div>

                <div id='contactData'>

                    <div id="pnlSrn">
        <strong>Staff number:</strong> <span id="lblSrn">ABC1234</span>
    </div>


                    <div id="pnlEmailAddress">
        <strong>Email Address:</strong> <span id="lblEmailAddress">Email</span>
    </div>
                    <div style="clear: both"></div>
                </div>

</div>

            <div id="pnlGrid">

                <h3><span id="lblGridTitle">Name's team</span></h3>
            <div>
        <table class="subordinates" cellspacing="0" cellpadding="2" rules="cols" border="1" id="gvEmployees" style="border-style:None;border-collapse:collapse;">
            <tr style="color:Black;background-color:#EFF3FB;border-style:None;font-weight:bold;">
                <th scope="col"><a href="javascript:__doPostBack('gvEmployees','Sort$SRN')" style="color:Black;">SRN</a></th><th scope="col"><a href="javascript:__doPostBack('gvEmployees','Sort$FullName')" style="color:Black;">Full name</a></th><th scope="col"><a href="javascript:__doPostBack('gvEmployees','Sort$RACFID')" style="color:Black;">RACFID</a></th>
            </tr><tr class="reports" style="background-color:White;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl02_lnkFullName" href="index.aspx?srn=1K5932" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:#EFF3FB;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl03_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:White;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl04_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:#EFF3FB;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl05_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:White;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl06_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:#EFF3FB;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl07_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:White;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl08_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:#EFF3FB;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl09_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:White;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl10_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="reports" style="background-color:#EFF3FB;border-style:None;">
                <td style="width:70px;">ABC1234</td><td>
                            <a id="gvEmployees_ctl11_lnkFullName" href="/path/to/index.aspx?srn=ABC1234" target="_self">Name Surname</a> 
                        </td><td>ABCD</td>
            </tr><tr class="PagerStyle" style="color:#000039;border-style:None;">
                <td colspan="3"><table border="0">
                    <tr>
                        <td><span>1</span></td><td><a href="javascript:__doPostBack('gvEmployees','Page$2')" style="color:#000039;">2</a></td>
                    </tr>
                </table></td>
            </tr>
        </table>
    </div>

</div>
            </div>

            <div id="searchBox">
                <strong>Search People Finder:</strong>
                <br /><br />
                <span>Forename:</span><br/>
                <span><input name="txtFirstname" type="text" id="txtFirstname" /></span><br/>
                <span>Surname:</span><br/>
                <span><input name="txtSurname" type="text" id="txtSurname" /></span><br/>
                <span>RACFID:</span><br/>
                <span><input name="txtRacfid" type="text" id="txtRacfid" /></span><br/>
                <span>Staff number:</span><br/>
                <span><input name="txtSrn" type="text" id="txtSrn" /></span><br/>
                <div class="searchBoxItem" style="text-align:center;width:100%"><input type="submit" name="btnFind" value="Search" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;btnFind&quot;, &quot;&quot;, false, &quot;&quot;, &quot;index.aspx&quot;, false, false))" id="btnFind" title="Search for employees member" class="button" style="border-style:Outset;" /></div><br/> 
                <div>People Finder searches only UK staff.</div> 
               <!-- <div><a class="execBoardLink" href="/path/to/index.aspx?srn=ABC1234">Show Executive Board</a></div> -->
                <div style="margin-top:5px;"><a href="/path/to/phonebook" target="phoneBook" onclick='return OpenPhonebook();' title="Open Phonebook in new window">Open Phonebook</a></div>
            </div>
        </div>

        <div class="contentFooter"  style="text-align:center;">
            <table width="100%" cellpadding="0" cellspacing="0" border="0" summary="Navigation layout table">
                <tr>
                    <td align="left"><span class="linkArrow">&lt;</span> <a href="javascript:history.back();">Back</a></td>
                    <td align="center"></td>
                    <td align="right"><span class="linkArrow">^ </span><a href="#top">Top</a></td>
                </tr>
            </table>
        </div> 

<div>

    <input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="vy066Txz34y1E515UsTSTDabHKEmdBRCsq7xM0lpJls1" />
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCgKM3uTTAgLP/83pDwLfwaTTAQKNguzjCAKt98LeCwLZh62pDwKKqdGpBwLd2q7jAwKa+5aMBAL5zb65C42zY4GBEUKujhjtZ/hZ8sLESfiF" />
</div></form>
</body>
</html>

解决方案

You could post a variable to the HTML page to go through the paging.

string lcUrl = "http://www.mysite.com/page.aspx";

HttpWebRequest loHttp =

   (HttpWebRequest) WebRequest.Create(lcUrl);


// *** Send any POST data

string lcPostData =

   "gvEmployees=" + HttpUtility.UrlEncode("Page$2");

loHttp.Method="POST";

byte [] lbPostBuffer = System.Text.           

                       Encoding.GetEncoding(1252).GetBytes(lcPostData);

loHttp.ContentLength = lbPostBuffer.Length;

Stream loPostData = loHttp.GetRequestStream();

loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);

loPostData.Close();

HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();

Encoding enc = System.Text.Encoding.GetEncoding(1252);

StreamReader loResponseStream =

   new StreamReader(loWebResponse.GetResponseStream(),enc);

string lcHtml = loResponseStream.ReadToEnd();

loWebResponse.Close();

loResponseStream.Close();

Then parse out the data you need from the string.

--EDIT--

Here is what I would try (something similar) where all of the post data is sent:

string lcPostData =

       "__EVENTTARGET" + HttpUtility.UrlEncode("gvEmployees"); &
"__EVENTARGUMENT" + HttpUtility.UrlEncode("Page%242"); &
"__VIEWSTATE" + HttpUtility.UrlEncode("<Value of _Viewstate>");

这篇关于我如何刮去ASP.NET网站信息正在使用分页和JavaScript链接时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆