Ejemplo n.º 1
0
        public async Task <WeatherInformation> ReadWeatherInformation(DateTime date)
        {
            GetUrl getUrl = (attempts) =>
            {
                return($"https://www.wunderground.com/history/daily/{location}/date/{date.ToString("yyyy-M-d")}");
            };

            var htmlDocument = await WebBrowserRequest.Navigate(getUrl, IsDocumentFullyLoaded, this.userInteraction, this.browser);

            if (GetReadings(htmlDocument, date, out List <WeatherReading> readings, out int dummy) &&
                GetLocationInformation(htmlDocument, out double latitude, out double longitude, out int dummy2))
            {
                WeatherInformation daylight = this.timeRangeProvider.GetInformation(this.userInteraction, date, latitude, longitude);

                if (daylight != null)
                {
                    return(new WeatherInformation(
                               daylight.StartTime,
                               daylight.EndTime,
                               readings));
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
 public static async Task <HtmlAgilityPack.HtmlDocument> Navigate(
     GetUrl getUrl,
     IsDocumentFullyLoaded isDocumentFullyLoaded,
     IUserInteraction userInteraction,
     IWebBrowser browser)
 {
     using (var request = new WebBrowserRequest(browser, getUrl, isDocumentFullyLoaded, userInteraction))
     {
         return(await request.Navigate());
     }
 }