我用的是c# 运行到:url = System.Web.HttpUtility.UrlEncode(url,System.Text.Encoding.GetEncoding("GB2312")); 时提示: 'System.UriFormatException' is a 'type', which is not valid in the given context D:\vsbin\pro\spider\spider\WindowsApplication1\Form1.cs 34 30 WindowsApplication1
在system.web下也找不到httpUtility方法
以解决: string url ="";//你的网址 string temp=""; System.Net.WebRequest wreq=System.Net.WebRequest.Create(url); System.Net.HttpWebResponse wresp=(System.Net.HttpWebResponse)wreq.GetResponse(); System.IO.Stream s=wresp.GetResponseStream(); System.IO.StreamReader sr = new System.IO.StreamReader(s,System.Text.Encoding.GetEncoding("gb2312")); temp=sr.ReadToEnd();//temp为你读的网页内容.谢谢dugupiaoyun(独孤飘云),谢谢大家
*****************************************************************************
欢迎使用CSDN论坛阅读器 : CSDN Reader(附全部源代码)
http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
如果你是读网页内容的话即使没那个控件也可以的啊。
string url ="";//你的网址
url = System.Web.HttpUtility.UrlEncode(url,System.Text.Encoding.GetEncoding("GB2312"));
string temp="";
System.Net.WebRequest wreq=System.Net.WebRequest.Create(url);
System.Net.HttpWebResponse wresp=(System.Net.HttpWebResponse)wreq.GetResponse();
System.IO.Stream s=wresp.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(s,System.Text.Encoding.GetEncoding("gb2312"));
temp=sr.ReadToEnd();//temp为你读的网页内容.
运行到:url = System.Web.HttpUtility.UrlEncode(url,System.Text.Encoding.GetEncoding("GB2312"));
时提示: 'System.UriFormatException' is a 'type', which is not valid in the given context D:\vsbin\pro\spider\spider\WindowsApplication1\Form1.cs 34 30 WindowsApplication1
string url ="";//你的网址
string temp="";
System.Net.WebRequest wreq=System.Net.WebRequest.Create(url);
System.Net.HttpWebResponse wresp=(System.Net.HttpWebResponse)wreq.GetResponse();
System.IO.Stream s=wresp.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(s,System.Text.Encoding.GetEncoding("gb2312"));
temp=sr.ReadToEnd();//temp为你读的网页内容.谢谢dugupiaoyun(独孤飘云),谢谢大家