Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading.Tasks;
- using System.Net.Http;
- namespace lab1
- {
- class Program
- {
- static readonly HttpClient client = new HttpClient();
- static async Task Main()
- {
- Console.WriteLine("Podaj adres strony: ");
- Console.Write("http://www.");
- string url = "http://www." + Console.ReadLine();
- try
- {
- Console.WriteLine("Trwa zliczanie znaków...");
- HttpResponseMessage response = await client.GetAsync(url);
- response.EnsureSuccessStatusCode();
- string responseBody = await response.Content.ReadAsStringAsync();
- Console.WriteLine(responseBody.Length);
- }
- catch (HttpRequestException e)
- {
- Console.WriteLine("\nBledny adres lub strona nie istnieje.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement