ברוכים הבאים לאתר השאלות והתשובות. מקום בו תוכלו לשאול כל שאלה ולקבל תשובות מהקהילה. יצירת קשר במייל aviboots(AT)netvision.net.il

התגיות הפופולריות ביותר

c#

כיצד לקרוא דף אינטרנט

0 אהבו 0 לא אהבו
105 views
asked Nov 5, 2013 in C# תכנות על-ידי avibootz (3,230 נקודות)

תשובה אחת

0 אהבו 0 לא אהבו

using System;
using System.Net;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // example 1
            using (var client = new WebClient())
            {
                string htmlText = client.DownloadString("http://www.aop.com");

                Console.WriteLine(htmlText);
            }

            // example 2
            try
            {
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.webshopy.com/");
                WebResponse response = (HttpWebResponse)request.GetResponse();
                Stream stream = response.GetResponseStream();
                StreamReader reader = new StreamReader(stream);
                string htmlText = reader.ReadToEnd();
                reader.Close();
                response.Close();

                Console.WriteLine(htmlText);
            }
            catch (WebException we)
            {
                Console.WriteLine(we.ToString());
            }
        }
    }
}

XLOVE אתר היכרויות

answered Nov 5, 2013 על-ידי avibootz (3,230 נקודות)
...