我使用HttpWebrequest
从google.I使用代理服务器来获取data.now有一个奇怪的问题,对于一些查询其返回的数据得到的结果和对一些人来说抛出异常The remote server returned an error: (503) Server Unavailable.
。 有人可能会认为代理是坏的,但是当你把它在Internet Explorer,然后打开Google是there.no 503错误then.but httpwebrequest
赋予它某些query.ie如果你打算让
http://www.google.com/search?q=site:http://www.yahoo.com
它会抛出例外,因为如果你去
http://www.google.com/search?q=info:http://www.yahoo.com
有用。
到目前为止我的代码是
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(file);
request.ProtocolVersion = HttpVersion.Version11;
request.Method = "GET";
request.KeepAlive = false;
request.ContentType = "text/html";
request.Timeout = 1000000000;
request.ReadWriteTimeout = 1000000000;
request.UseDefaultCredentials = true;
request.Credentials = CredentialCache.DefaultCredentials;
Uri newUri = new Uri("http://" + proxy[selectedProxy].ProxyAddress.Trim() + "/");
WebProxy myProxy = new WebProxy();
myProxy.Credentials = CredentialCache.DefaultCredentials;
myProxy.Address = newUri;
request.Proxy = myProxy;
WebResponse response = request.GetResponse();
// System.Threading.Thread.Sleep(Delay);
StreamReader reader = null;
string data = null;
reader = new StreamReader(response.GetResponseStream());
data = reader.ReadToEnd();