Пример #1
0
    def _weekend_forecast(self, args):
        criteria = {
            'weather-cell': 'header',
            'temp': 'p',
            'weather-phrase': 'h3',
            'wind-conditions': 'p',
            'humidity': 'p'
        }
        mapper = Mapper()
        mapper.remap_key('wind-conditions', 'wind')
        mapper.remap_key('weather-phrase', 'description')
        mapper.remap_key('weather-cell', 'day-detail')
        content, driver = self._request.fetch_data(args.forecast_option.value,
                                                   args.latitude,
                                                   args.longitude)
        driver.close()

        bs = BeautifulSoup(content, 'html.parser')

        forecast_data = bs.find('section', class_='ls-mod')

        container = forecast_data.div.div
        partial_results = self._parse(container, criteria)
        results = mapper.remap(partial_results)

        return self._prepare_data(results, args, 3)
Пример #2
0
    def _weekend_forecast(self, args):
        criteria = {
            'weather-cell': 'header',
            'temp': 'p',
            'weather-phrase': 'h3',
            'wind-conditions': 'p',
            'humidity': 'p',
        }

        mapper = Mapper()
        mapper.remap_key('wind-conditions', 'wind')
        mapper.remap_key('weather-phrase', 'description')

        content = self._request.fetch_data(args.forecast_option.value,
                                           args.area_code)

        soup = BeautifulSoup(content, 'html.parser')

        forecast_data = soup.find('article', class_='ls-mod')
        container = forecast_data.div.div

        partial_results = self._parse(container, criteria)
        results = mapper.remap(partial_results)

        return self._prepare_data(results, args)
    def _weekend_forecast(self, args):
        bs = self._make_http_request(args)

        container = bs.find('section', class_ = 'ls-mod').div.div
        criteria = {
            'weather-cell': 'header',
            'temp': 'p',
            'weather-phrase': 'h3',
            'wind-conditions': 'p',
            'humidity': 'p'
        }
        partial_results = self._parse(container, criteria)

        mapper = Mapper()
        mapper.remap_key('wind-conditions', 'wind')
        mapper.remap_key('weather-phrase', 'description')
        results = mapper.remap(partial_results)

        return self._prepare_data(results, args)
    def _ten_day_forecast(self, args):
        bs = self._make_http_request(args)

        container = bs.find("section", {"data-testid": "DailyForecast"}).find("div", { "class": re.compile("DisclosureList")})
        criteria = [
            ("h3", "data-testid", "daypartName"),
            ("div", "data-testid", "wxIcon"),
            ("div", "data-testid", "detailsTemperature"),
            ("span", "data-testid", "Wind"),
            ("span", "data-testid", "PercentageValue")
        ]
        results = self._parse(container, criteria)

        # 10 day forecast actually returns 15 days. Pare the list down
        results = results[:10]

        mapper = Mapper()
        mapper.remap_key('daypartName', 'date-time')
        mapper.remap_key('wxIcon', 'description')
        mapper.remap_key('detailsTemperature', 'temp')
        mapper.remap_key('Wind', 'wind')
        mapper.remap_key('PercentageValue', 'humidity')
        results = mapper.remap(results)

        return self._prepare_data(results, args)