Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.2 kB
2
Indexable
Never
using System;
using System.Net;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string nips;
                Console.Write("Podaj nipy(max 30) ");
                Console.WriteLine();
                nips = Console.ReadLine();
                nips = nips.Replace(';', ',');
                string url;
                url = "https://wl-api.mf.gov.pl/api/search/nips/" + nips + "?date=2021-07-04";
                Console.Write("url zapytania: " + url);
                Console.WriteLine();

                System.Net.WebClient client = new WebClient();

                Byte[] pageData = client.DownloadData(url);
                string pageHtml = Encoding.ASCII.GetString(pageData);
                
                Console.WriteLine(pageHtml);

            }
            catch (WebException webEx)
            {
                Console.WriteLine(webEx.ToString());
                if (webEx.Status == WebExceptionStatus.ConnectFailure)
                {
                    Console.WriteLine("Cos sie popsulo");
                }
            }
        }
    }
}