首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-10-23 
跨越代理取得uri数据的方法[C#]??????????? HttpWebRequest request (HttpWebRequest)HttpWebRequest.Cr

跨越代理取得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();

?

?

热点排行