首页 > 代码库 > 获取windows身份认证网站页面内容

获取windows身份认证网站页面内容

有些网站必须登录才能获取到页面内容。

技术分享

代码如下,可获取数据。

   var url = "https://yunda-api-test.appspot.com/int/parcel?wait=true";            var uid = "1@test";            var pwd = "97878";            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;            request.Method = "GET";            // Add authentication to request              request.Credentials = new NetworkCredential(uid, pwd);            var text = string.Empty;            // Get response              using (WebResponse response = request.GetResponse())            {                // Get the response stream                  StreamReader reader = new StreamReader(response.GetResponseStream());                // Console application output                  text = reader.ReadToEnd();            }            Console.WriteLine(text);

 获取数据得到 如下图

技术分享

 

获取windows身份认证网站页面内容