獲取windows身份認證網站頁面內容

有些網站必須登陸才能獲取到頁面內容。api

代碼以下,可獲取數據。app

   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);

 獲取數據獲得 以下圖網站

相關文章
相關標籤/搜索