读取网页图片(包含代理)
WebRequest webRequest = WebRequest.Create("http://54.248.92.120/dscservice_api/api/person/632_12345.jpg"); WebProxy p = null; //代理类 string proxyAddressAndPort = "guruproxy.bqc.corp.com"; string proxyUserName = "账号"; string proxyPwd = "密码"; ICredentials cre; //身份验证信息类 cre = new NetworkCredential(proxyUserName, proxyPwd); //得到用户名和密码 p = new WebProxy(proxyAddressAndPort, true, null, cre); //将信息放于代理类中(代理服务器URl,是否跳过代理,,身份验证信息) WebRequest.DefaultWebProxy = p; HttpWebRequest request = webRequest as HttpWebRequest; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string encoding = response.ContentEncoding; StreamReader reader = new StreamReader(response.GetResponseStream()); var xx = reader.ReadToEnd(); byte[] picbyte = Encoding.Default.GetBytes(xx);