现在遇到这么个问题 数据抓取时,当查看下一页时候页面url没有改变,我通过什么办法得到下一页,并得到下一页网页源文件信息,要抓取的页面是 http://dc.shian.gov.cn/sww/ReportSearchRouPin.aspx
1,按钮点击模拟 但这种方法怎么去操作?诚心请教高手!

解决方案 »

  1.   

    网页不变,但会提交一些信息,然后返回刷新局部,你用wpe工具抓一下包,然后按照包中的信息,组织自己的包信息,然后模拟提交
      

  2.   

    protected void Button1_Click(object sender, System.EventArgs e)
    {
    //获取html信息开始
    string strHttp="";
    try
    {
    string strEncoding="gb2312";
    if(RadioButtonUtf.Checked)
    {
    strEncoding="utf-8";
    }
    string strUrl=TextBoxUrl.Text;
    HttpWebRequest request = (HttpWebRequest) WebRequest.Create(strUrl);

    request.Timeout = 10000; // 10秒
    request.UserAgent = "Code Sample Web Client";

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Encoding encoding= Encoding.GetEncoding(strEncoding);

    StreamReader reader =new StreamReader(response.GetResponseStream(),encoding);
    strHttp=reader.ReadToEnd(); response.Close();
    reader.Close();
    }
    catch(IOException ep)
    {
    Response.Write(ep.Message.ToString());
    }
    //获取html信息结束 string strHtml=strHttp.ToLower();
    strHtml=html(strHtml);
    //去除<script>\<style>
    strHtml=strHtml.Replace("/script>","/script>\n");
    strHtml=strHtml.Replace("/style>","/style>\n");
    strHtml=strHtml.Replace("&nbsp;","");

    string str="<script.{0,}script>|<style.{0,}style>";
    string strValue=""; Regex regex=new Regex(str);
    Match match=regex.Match(strHtml);
    while (match.Success)
    {
    strValue=match.Value;
    strHtml=strHtml.Replace(strValue,"");
    match=regex.Match(strHtml);
    }
    ///去除<...>
    strHtml=strHtml.Replace(">",">\n");

    str="<.{0,}>|&.{0,6};|http.{0,}>";
    ///替换<...>及&类html代码
    ///http.{0,}为有些网页错误代码过滤 regex=new Regex(str);
    match=regex.Match(strHtml);
    while (match.Success)
    {
    strValue=match.Value;
    strHtml=strHtml.Replace(strValue,"");
    match=regex.Match(strHtml);
    }
    for(int i=0;i<20;i++)//过滤多余空格
    {
    strHtml=strHtml.Replace("  "," ");
    }

    LabelHtml.Text=html(strHtml); }

    private string html(string inputString) ///替换字符串
    {
    StringBuilder retVal = new StringBuilder();     ///构造临时字符串数组
    if ((inputString != null) && (inputString != String.Empty)) 
    {
    for (int i = 0; i < inputString.Length; i++) 
    {
    switch(inputString[i])            ///替换字符串
    {
    case '\r':retVal.Append("");break;
    case '\n':retVal.Append("");break;
    case '\t':retVal.Append("");break;
    case '"' :retVal.Append("'");break;
    default:retVal.Append(inputString[i]);break;
    }
    }
    }
    string outString=retVal.ToString();
    return outString;
    }
      

  3.   

    第一页数据抓取已经实现,现在就是无法得到下一页,同时也没有url地址,想问的是 如何得到下一页?
      

  4.   

    要抓取的页面信息 分页时就只有这几个信息
     <input type="image" name="MiddleShuCai$ButtPageNext" id="MiddleShuCai_ButtPageNext" src="./Images/pagedown.gif" style="border-width:0px;" />这个是下一页的按钮
    如何得到下一页 只有模拟分页得到下一页吗?如果是这样怎么实现的