苏飞论坛
标题:
关于抓取网页源码,求苏飞大神帮忙
[打印本页]
作者:
kunkun0921
时间:
2014-6-27 08:50
标题:
关于抓取网页源码,求苏飞大神帮忙
连接:
http://202.114.153.37/zkb/bkcx/bkcx.asp?database=bk201407&showlx=11
号码:014614110881
这是使用你的Helper类实现的,但是不行。
string url = "
http://202.114.153.37/zkb/bkcx/cjlist.asp
";
string data = "showlx=&database=bk201407&tkz=" + number + "&B1=%CC%E1%BD%BB";
Encoding gb2312 = Encoding.GetEncoding("GB2312");
HttpResult result = httpHelper.GetHtml(new HttpItem()
{
URL = "
http://202.114.153.37/zkb/bkcx/cjlist.asp
",
Postdata=data
});
后来我自己写了一个方法,但是值没有传递进去
string requestString = "showlx=&database=bk201407&tkz=" + number + "&B1=%CC%E1%BD%BB";
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
request.Method = "POST";
request.ContentLength = requestString.Length;
request.ContentType = "text/xml";
gb2312 = Encoding.GetEncoding("gb2312");
byte[] bytes = Encoding.Default.GetBytes(requestString);
System.IO.Stream stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
stream.Close();
System.Net.HttpWebResponse response;
System.IO.StreamReader streamReader;
response = (System.Net.HttpWebResponse)request.GetResponse();
streamReader = new StreamReader(response.GetResponseStream(), gb2312);
StringBuilder sb = new StringBuilder();
char[] respChar = new char[1024];
int BytesRead = 0;
BytesRead = streamReader.Read(respChar, 0, 1024);
while (BytesRead > 0)
{
sb.Append(respChar, 0, BytesRead);
BytesRead = streamReader.Read(respChar, 0, 1024);
}
streamReader.Close();
只需要值post进去就好了。
作者:
站长苏飞
时间:
2014-6-27 08:56
http://www.sufeinet.com/thread-3-1-1.html
我 建议你去看看教程,或者使用我的生成器
http://www.sufeinet.com/thread-3690-1-1.html
我可从来没教过你们Post是这样写的,
HttpResult result = httpHelper.GetHtml(new HttpItem()
{
URL = "http://202.114.153.37/zkb/bkcx/cjlist.asp",
Postdata=data
});
你随便找我一个例子看看就懂了,你这是用的Get,
作者:
kunkun0921
时间:
2014-6-27 09:07
非常感谢大神,我昨天也这样试过,没有成功,但是昨天的参数设置比今天多,但是今天却成功了。
作者:
dyyyj
时间:
2014-6-27 10:35
楼上的兄弟,能否把你的源码给我看一下。我试了一下。没成功
作者:
liu67667
时间:
2014-10-31 14:33
膜拜中....!
欢迎光临 苏飞论坛 (http://www.sufeinet.com/)
Powered by Discuz! X3.4