读书人

逾越代理取得uri数据的方法[C#]

发布时间: 2012-10-23 12:12:22 作者: rapoo

跨越代理取得uri数据的方法[C#]

??????????? HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(http://hq.sinajs.cn/list=sh000001);
??????????? WebProxy myProxy = new WebProxy();
??????????? myProxy.Address = new Uri("http://proxy:port");
??????????? myProxy.Credentials = new NetworkCredential("username", "password");
??????????? request.Proxy = myProxy;

??????????? HttpWebResponse response = (HttpWebResponse)request.GetResponse();
??????????? Stream respStream = response.GetResponseStream();
??????????? StreamReader reader = new StreamReader(respStream);
??????????? string line = reader.ReadLine();

?

?

读书人网 >C#

热点推荐