string http = "http://www.baidu.com";
System.Net.WebRequest request = System.Net.WebRequest.Create(http);
System.IO.StreamReader sr = new System.IO.StreamReader(request.GetResponse().GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));我想抓取一个网页,同一个网址,在浏览器里输是有值的,用上面这段代码却无返回值,但用上面这代码搜百度是有值的
这是为什么?是不是那网站用了什么技术屏蔽抓取,怎么解决?
解决方案 »
- 请教一个GridView问题。
- 急急!!如何过滤脏话??
- 如何在后台修改<body>的样式?
- Repeater控件的循环显示
- 极为简单的用FileUpload配合SqlDataSource把文件存入varbinary字段的问题。
- 请教ExecuteReader为何不能读取最后一条记录???
- 请问大家网站注册验证码输入是为了什么哦
- 监控站点访问量问题?
- 我想用一条SQL语句来分页,但是又不懂得那条SQL的意思。
- 未处理 MyCement.Database.AdoNet.AdoException
- ASP.NET与javaScript的交互问题,关于百度地图API
- 名称中不能包含“(”字符(十六进制值 0x28)???
http://www.cnblogs.com/lixiaofei/archive/2012/02/16/2353795.html
http://ribao.xoyo.com/jx3/92/:info=jx3_query_price%23server_k%3D0%23server_name%3D%E6%A2%A6%E6%B1%9F%E5%8D%97%2F%E5%A6%82%E6%A2%A6%E4%BB%A4%2F%E6%9E%AB%E6%B3%BE%E5%8F%A4%E9%95%87%23article_name%3D%E7%A7%98%E6%96%B9%EF%BC%9A%E7%82%B8%E6%98%A5%E5%8D%B7%23pageno%3D1%23order_column%3Dbin_high_price%23order_type%3DASC%23nu%3D这条网址在浏览器中会返回一个josn字符串,如下var data = {"list":[{"aid":"77692","article_name":"\u79d8\u65b9\uff1a\u70b8\u6625\u5377","article_nums":"2","nSortID":"8","tSubSort":"2","bin_high_price":"12500000","bin_low_price":"12500000","bin_average_price":"12500000","a_high_price":"12000000","a_low_price":"12000000","a_average_price":"12000000","server_k":"0","server_name":"\u68a6\u6c5f\u5357\/\u5982\u68a6\u4ee4\/\u67ab\u6cfe\u53e4\u9547","operatetime":"2012-02-17 03:45:17"}],"config":["\u7535\u4fe1","\u7f51\u901a"],"counts":"1"}
但在程序里就返回一个空串了,如下var data = {\"list\":null,\"config\":[\"\\u7535\\u4fe1\",\"\\u7f51\\u901a\"],\"counts\":\"0\"}
怎么办
如果"/"是传的值,理应进行编码,要不与目录容易搞混
string sItemName = "秘方:炸春卷";
string http = "http://ribao.xoyo.com/jx3/190/:info=jx3_query_price";
string query = "#server_k=0#server_name=梦江南/如梦令/枫泾古镇#article_name=" + sItemName + "#pageno=1#order_column=bin_high_price#order_type=ASC#nu="; http = http + HttpUtility.UrlEncode (query);//Microsoft.JScript.GlobalObject.encodeURIComponent(query);
System.Net.WebRequest request = System.Net.WebRequest.Create(http);
System.IO.StreamReader sr = new System.IO.StreamReader(request.GetResponse().GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));
if (sr != null)
{
string html = sr.ReadToEnd();
}