예제 #1
0
        internal static WebsiteDataModel WsDownloadSycn(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = client.DownloadString(websiteURL);

            return(output);
        }
예제 #2
0
        internal static async Task <WebsiteDataModel> WsDownloadAsycn(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL);

            return(output);
        }
예제 #3
0
        public static List <WebsiteDataModel> RunWebSiteDownloadSync()
        {
            List <string>           websites = GetURLs();
            List <WebsiteDataModel> output   = new List <WebsiteDataModel>();

            Console.WriteLine("download is in progress for site.. ");
            foreach (string site in websites)
            {
                Console.Write($"[{DateTime.UtcNow.Second}.{DateTime.UtcNow.Millisecond}] Download started for {site}");
                WebsiteDataModel results = WsDownloadSycn(site);
                Console.WriteLine($"..completed [{DateTime.UtcNow.Second}.{DateTime.UtcNow.Millisecond}].");
                output.Add(results);
            }
            return(output);
        }
예제 #4
0
        internal static async Task <WebsiteDataModel> WsDownloadPrallelAsycn(string websiteURL)
        {
            System.Diagnostics.Debug.WriteLine(websiteURL);
            Console.WriteLine($"[{DateTime.UtcNow.Second}.{DateTime.UtcNow.Millisecond}] " +
                              $"Download started for {websiteURL}");
            //$"Download started for {websiteURL.Substring(0,websiteURL.IndexOf('/',8))}");

            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL);

            //Console.WriteLine($"..completed[{DateTime.UtcNow.Second}.{DateTime.UtcNow.Millisecond}].");
            return(output);
        }
예제 #5
0
 internal static void ReportWebSiteInfo(WebsiteDataModel dataModel)
 {
     Console.WriteLine($"{ dataModel.WebsiteUrl } downloaded: { dataModel.WebsiteData.Length } characters long.{ Environment.NewLine }");
 }