想用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 );
} }
}
}
}
第一个: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 );
} }
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货