Exemplo n.º 1
0
        public async Task <StationsResonse> GetStationsAsync(UzContext context, string term)
        {
            string normalizedTerm = HttpUtility.UrlEncode(HttpUtility.UrlDecode(term));

            using (CookieSupportatbleHttpClient client = CreateHttpClient(context)) {
                HttpResponseMessage response = await client.GetAsync(UrlStation + $"?term={normalizedTerm}");

                string rawStations = await response.Content.ReadAsStringAsync();

                return(ResponseFormatter.FormatStations(rawStations));
            }
        }
Exemplo n.º 2
0
        public async Task <UzContext> GetUZContextAsync()
        {
            using (CookieSupportatbleHttpClient client = CreateHttpClient()) {
                HttpResponseMessage response = await client.GetAsync(BaseUrl);

                string mainPageHtml = await response.Content.ReadAsStringAsync();

                string           token   = TokenDecoder.Decode(mainPageHtml);
                CookieCollection cookies = client.ReadCookies(response);
                return(new UzContext(token, cookies));
            }
        }