我正在尝试使用公共代理服务器(http://www.unblockwebnow.info/)向目标站点发送HTTP请求,比如http://stackoverflow.com :)
我的HTTP客户端具有以下架构:
string url = "http://stackoverflow.com";
HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWRequest.Method = "GET";
WebProxy myProxy = new WebProxy();
myProxy.Address = new Uri("http://www.unblockwebnow.info/");
HttpWRequest.Proxy = myProxy;
HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWRequest.GetResponse();
StreamReader sr = new StreamReader(HttpWResponse.GetResponseStream(), encoding);
var rawHTML = sr.ReadToEnd();
sr.Close();
Run Code Online (Sandbox Code Playgroud)
在执行rawHTML的代码后,我得到了 "pageok -managed by puppet - hostingcms02 pageok"
如果我注释掉HttpWRequest.Proxy = myProxy;,我会得到网站内容.