protected WeatherDataDto Fetch(HtmlDocument htmlDocument, ParseInfo parseInfo) { var description = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/*[@class='img weatherIcoS']/td[{1}]/div", parseInfo.Day, parseInfo.TimeOfDay); var airTemp = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/*[@class='temperature']/td[{1}]", parseInfo.Day, parseInfo.TimeOfDay); var realFeel = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/*[@class='temperatureSens']/td[{1}]", parseInfo.Day, parseInfo.TimeOfDay); var pressure = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/*[@class='gray']/td[{1}]", parseInfo.Day, parseInfo.TimeOfDay); var windDirection = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/*[@class='gray']/td[{1}]/div", parseInfo.Day, parseInfo.TimeOfDay); var windSpeed = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/*[@class='gray']/td[{1}]/div", parseInfo.Day, parseInfo.TimeOfDay); var humidity = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/tr[6]/td[{1}]", parseInfo.Day, parseInfo.TimeOfDay); var chancePrecipitation = this.Format("//*[@id='bd{0}c']/div/div[2]/table/tbody/tr[8]/td[{1}]", parseInfo.Day, parseInfo.TimeOfDay); var date = "//*[@id='bd{0}']/p/a".F(parseInfo.Day); return new WeatherDataDto { Provider = Provider.Sinoptik, ProviderName = "Sinoptic", DateTime = this.GetDate(htmlDocument.GetAttribute(date, "data-link"), parseInfo.TimeOfDayKey), Cloudy = this.ConvertCloudy(htmlDocument.GetAttribute(description, "title")), Precipitation = this.ConvertPrecipitation(htmlDocument.GetAttribute(description, "title")), StrengthPrecipitation = this.ConvertStrengthPrecipitation(htmlDocument.GetAttribute(description, "title")), IsFog = this.ConvertFog(htmlDocument.GetAttribute(description, "title")), IsThunderstorm = this.ConvertThunderstorm(htmlDocument.GetAttribute(description, "title")), AirTemp = this.ConvertTemp(htmlDocument.GetInnerText(airTemp)), RealFeel = this.ConvertTemp(htmlDocument.GetInnerText(realFeel)), Pressure = Double.Parse(htmlDocument.GetInnerText(pressure)), WindDirection = this.ConvertWindDirection(htmlDocument.GetAttribute(windDirection, "data-tooltip")), WindSpeed = this.ConvertWindSpeed(htmlDocument.GetInnerText(windSpeed)), Humidity = Double.Parse(htmlDocument.GetInnerText(humidity)), ChancePrecipitation = this.ConvertChancePrecipitation(htmlDocument.GetInnerText(chancePrecipitation)) }; }
protected WeatherDataDto Fetch(HtmlDocument htmlDocument, ParseInfo parseInfo) { var description = "//*[@id='tbwdaily{0}']/tr[{1}]/td[@class='cltext']".F(parseInfo.Day, parseInfo.TimeOfDay); var airTemp = "//*[@id='tbwdaily{0}']/tr[{1}]/td[@class='temp']/*[@class='value m_temp c']".F(parseInfo.Day, parseInfo.TimeOfDay); var realFeel = "//*[@id='tbwdaily{0}']/tr[{1}]/td[7]/*[@class='value m_temp c']".F(parseInfo.Day, parseInfo.TimeOfDay); var pressure = "//*[@id='tbwdaily{0}']/tr[{1}]/td/*[@class='value m_press torr']".F(parseInfo.Day, parseInfo.TimeOfDay); var windDirection = "//*[@id='tbwdaily{0}']/tr[{1}]/td/dl[@class='wind']/dt".F(parseInfo.Day, parseInfo.TimeOfDay); var windSpeed = "//*[@id='tbwdaily{0}']/tr[{1}]/td/dl/dd/*[@class='value m_wind ms']".F(parseInfo.Day, parseInfo.TimeOfDay); var humidity = "//*[@id='tbwdaily{0}']/tr[{1}]/td[6]".F(parseInfo.Day, parseInfo.TimeOfDay); var date = "//*[@id='tbwdaily{0}']/tr[1]".F(parseInfo.Day); return new WeatherDataDto { Provider = Provider.Gismeteo, ProviderName = "Gismeteo", DateTime = this.GetDate(htmlDocument.GetAttribute(date, "id"), parseInfo.TimeOfDayKey), Cloudy = this.ConvertCloudy(htmlDocument.GetInnerText(description)), Precipitation = this.ConvertPrecipitation(htmlDocument.GetInnerText(description)), StrengthPrecipitation = this.ConvertStrengthPrecipitation(htmlDocument.GetInnerText(description)), IsFog = this.ConvertFog(htmlDocument.GetInnerText(description)), IsThunderstorm = this.ConvertThunderstorm(htmlDocument.GetInnerText(description)), AirTemp = this.ConvertTemp(htmlDocument.GetInnerText(airTemp)), RealFeel = this.ConvertTemp(htmlDocument.GetInnerText(realFeel)), Pressure = Double.Parse(htmlDocument.GetInnerText(pressure)), WindDirection = this.ConvertWindDirection(htmlDocument.GetInnerText(windDirection)), WindSpeed = Double.Parse(htmlDocument.GetInnerText(windSpeed)), Humidity = Double.Parse(htmlDocument.GetInnerText(humidity)) }; }
protected WeatherDataDto Fetch(HtmlDocument htmlDocument, ParseInfo parseInfo) { var cloudy = GetXPath(htmlDocument, "Облачность", "/td[{0}]/div[1]/div".F(parseInfo.TimeOfDay)); // In one time of day two description var description = GetXPath(htmlDocument, "Явления погоды", "/td[{0}]/div[1]".F(parseInfo.TimeOfDay * 2 - 2)); var isFog = "//*[@id='forecastTable']/tr[5]/td[{0}]/div[1]".F(parseInfo.TimeOfDay - 1); var airTemp = GetXPath(htmlDocument, "Температура", "/td[{0}]/div[1]/b".F(parseInfo.TimeOfDay)); var realFeel = GetXPath(htmlDocument, "Ощущается", "/td[{0}]/div[1]".F(parseInfo.TimeOfDay)); var sameRealFeel = GetXPath(htmlDocument, "Ощущается", "/td[{0}]".F(parseInfo.TimeOfDay)); var pressure = "//*[@id='forecastTable']/tr[last()-7]/td[{0}]/div[1]/b|//*[@id='forecastTable']/tr[last()-7]/td[{0}]/div[1]".F(parseInfo.TimeOfDay); var windDirection = "//*[@id='forecastTable']/tr[last()-4]/td[{0}]".F(parseInfo.TimeOfDay); var windSpeed = GetAvailablePath(htmlDocument, "//*[@id='forecastTable']/tr[last()-6]/td[{0}]/div[1]".F(parseInfo.TimeOfDay), "//*[@id='forecastTable']/tr[last()-6]/td[{0}]".F(parseInfo.TimeOfDay)); var humidity = "//*[@id='forecastTable']/tr[last()-3]/td[{0}]".F(parseInfo.TimeOfDay); var date = "//*[@id='forecastTable']/tr[1]/td[{0}]/div/div/span[2]".F(parseInfo.Day); return new WeatherDataDto { Provider = Provider.Rp5, ProviderName = "Rp5", DateTime = this.GetDateInTable(htmlDocument.GetInnerText(date), parseInfo.TimeOfDayKey), Cloudy = this.ConvertCloudy(htmlDocument.GetAttribute(cloudy, "onmouseover")), Precipitation = this.ConvertPrecipitation(htmlDocument.GetAttribute(description, "onmouseover")), StrengthPrecipitation = this.ConvertStrengthPrecipitation(htmlDocument.GetAttribute(description, "onmouseover")), IsFog = this.ConvertFog(htmlDocument.IsAttribute(isFog, "onmouseover") ? htmlDocument.GetAttribute(isFog, "onmouseover") : string.Empty), IsThunderstorm = this.ConvertThunderstorm(htmlDocument.GetAttribute(description, "onmouseover")), AirTemp = Int32.Parse(htmlDocument.GetInnerText(airTemp)), RealFeel = this.ConvertRealFeel(htmlDocument, sameRealFeel, airTemp, realFeel), Pressure = Double.Parse(htmlDocument.GetInnerText(pressure)), WindDirection = this.ConvertWindDirection(htmlDocument.GetInnerText(windDirection)), WindSpeed = Double.Parse(htmlDocument.GetInnerText(windSpeed)), Humidity = Double.Parse(htmlDocument.GetInnerText(humidity)) }; }