想用HttpWebRequest直接请求http://61.186.254.4/cgszzxhweb/xh/jdcxxlr.jsp页面。然后用GetResponseStream,读出返回的页面。服务估计是侦测到我没有通过首页进入,直接就让我返回了首页。 感觉不是COOKIE的问题,是页面有JS验证问题。当我访问http://61.186.254.4/cgszzxhweb/index.jsp主页点击-----“自主编号”时, 通过GET方法 返回了2个页面。
  第一个:http://61.186.254.4/cgszzxhweb/validate/isTzxh.jsp
         返回的HTML内容为 :  ret={ flag:-1, isTzxh:'0', msg : "" } 
  第二个:http://61.186.254.4/cgszzxhweb/xh/xhfs.jsp
         返回的HTML内容才是我想要的,HTML代码略。
这个网站使用了锚记,完全把我弄糊涂了。我的目的想编写一个自动注册的程序,本人是菜鸟中的菜鸟不是计算机专业通过看来3天书。一阵乱弄。
希望有高人能帮帮我。
测试代码如下using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;namespace WindowsFormsApplication9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://61.186.254.4/cgszzxhweb/xh/jdcxxlr.jsp"); 
            req.Method = "GET";  
            using (WebResponse wr = req.GetResponse())
            {   
                CookieContainer cookie = new CookieContainer();
                Stream stm = wr.GetResponseStream();
                StreamReader mystreamreader = new StreamReader(stm);
                string html;
                while ((html = mystreamreader.ReadLine()) != null)
                {
                    listBox1.Items.Add(html );
                }           } 
        }
    }
}

解决方案 »

  1.   

    首先 HttpWebRequest 不涉及js,那是客户端语言 你请求的是文本 不会执行2,你说的对 是cookie问题 建议你先访问下首页,把访问后的cookie导入到第二次请求里就可以
      

  2.   

    那个cookie对应的是jsp页面session的值
      

  3.   

    啊,是真的吗? 其实我是想得到第二个页面,  但服务器返回的是第一个页面。   如果我直接请求第二个页面就跳回了首页,我只能从第一个页面开始,先请求第一个页面,返回“ret={ flag:-1, isTzxh:'0', msg : "" }”只有这一句话。明显感觉像是个值,但却是不明白JS是怎么传给服务器,转到第二个页面?
      

  4.   

    首先请求首页然后带着请求首页返回的cookie请求你需要的页面