c# 网页数据采集问题
下面的地址是我要采集数据的地址http://www.fpdisplay.com/controls/trade/ProductListBack.ashx?keyword=%u6DB2%u6676&id=&type=4&pagesize=10&curragepage=1
这个地址,在浏览器中打开,是有数据的。但是在代码中就没有数据了
我用了两种方式
1.
WebClient client = new WebClient();
client.Encoding = Encoding.GetEncoding("UTF-8");
string html = client.DownloadString("http://www.fpdisplay.com/controls/trade/ProductListBack.ashx?keyword=%u6DB2%u6676&id=&type=4&pagesize=10&curragepage=1");
2.
HttpWebRequest request = WebRequest.Create("http://www.fpdisplay.com/controls/trade/ProductListBack.ashx?keyword=%u6DB2%u6676&id=&type=4&pagesize=10&curragepage=1") as HttpWebRequest;
request.Method = "GET";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
request.KeepAlive = true;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
html = reader.ReadToEnd();
以上代码获取的结果都为空
各位,帮忙指点指点啊。。
--------------------编程问答-------------------- 顶顶up --------------------编程问答-------------------- 这个网页都打不开,怎么获取? --------------------编程问答-------------------- string param = "";
byte[] bs = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create( "" );
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = bs.Length;
--------------------编程问答--------------------
这个是下载,把下载的数据 处理 一下 就行了 --------------------编程问答-------------------- 问题解决了,是编码的问题。
WebClient client = new WebClient();
client.Encoding = Encoding.GetEncoding("UTF-8");
string html = client.DownloadString("http://www.fpdisplay.com/controls/trade/ProductListBack.ashx?keywords=改成具体汉字就OK了&id=&type=4&pagesize=10&curragepage=1"); --------------------编程问答-------------------- urldecode
捡分
补充:.NET技术 , C#