Exemplo n.º 1
0
    def parse_item(self, response):
        """ Creates a WineVendorsItem from the response """
        wine = VendorWine()
        wine['vendor'] = {
            'name': 'Nobel wijnkoperij',
            'url': self.allowed_domains[0]
        }
        wine['url'] = response.url
        wine['winery'] = ''
        wine['name'] = response.css(
            'meta[property="og:title"]::attr(content)').get()
        wine['price'] = float_or_none(
            response.css(
                'meta[property="product:price:amount"]::attr(content)').get())

        volume_label = response.css(
            '#product-attribute-specs-table td[data-th="Inhoud"]::text').get()
        if volume_label:
            wine['volume'] = float_or_none(
                volume_label.replace(',', '.').split(' ')[0])

        wine['year'] = response.css(
            '#product-attribute-specs-table td[data-th="Oogstjaar"]::text'
        ).get()

        yield wine
Exemplo n.º 2
0
    def parse_item(self, response):
        """ Creates a WineVendorsItem from the response """
        wine = VendorWine()
        wine['vendor'] = {'name': 'Wijnkoperij De Gouden Ton', 'url': self.allowed_domains[0]}
        wine['url'] = response.url
        wine['winery'] = find_property(response, 'Producent')
        wine['name'] = response.css('.product-name > h1::text').get()
        wine['price'] = float_or_none(response.css('meta[itemprop="price"]::attr(content)').get())
        wine['year'] = find_property(response, 'Oogst')
        wine['volume'] = float_or_none(find_property(response, 'inhoud').replace(',', '.'))

        yield wine
Exemplo n.º 3
0
    def parse_item(self, response):
        """ Creates a VendorWine from the response """
        wine = VendorWine()
        wine['vendor'] = {
            'name': self.name.title(),
            'url': self.allowed_domains[0]
        }
        wine['url'] = response.url

        data = response.xpath(
            '//script[@type="application/ld+json" and contains(text(), "Product")]/text()'
        ).get()
        d = json.loads(data)

        wine['winery'] = d.get('brand')
        wine['name'] = d.get('name')

        offers = d.get('offers', {})
        wine['price'] = float_or_none(offers.get('price'))
        wine['volume'] = 0.75
        wine['year'] = response.xpath(
            '//span[@class="item-details-title" and contains(text(), "Jaar")]/following-sibling::node()/text()'
        ).get()

        yield wine
Exemplo n.º 4
0
    def parse_item(self, response):
        """ Creates a VendorWine from the response """
        wine = VendorWine()
        wine['vendor'] = {
            'name': self.name.title(),
            'url': self.allowed_domains[0]
        }
        wine['url'] = response.url

        data = response.xpath(
            '//script[contains(text(), "productData")]/text()').get()
        m = re.search(pattern, data)
        if m is not None:
            d = json.loads(m.group(1))
            wine['winery'] = ''
            wine['name'] = d.get('name')
            wine['price'] = float_or_none(d.get('price'))

        wine['year'] = response.css('td[data-th="Jaargang"]::text').get()

        wine['volume'] = 0.75
        if 'magnum' in wine['url']:
            wine['volume'] = 1.5
        elif '0-375l' in wine['url']:
            wine['volume'] = .375

        yield wine
Exemplo n.º 5
0
    def parse_item(self, response):
        """ Creates a WineVendorsItem from the response """
        wine = VendorWine()
        wine['vendor'] = {
            'name': 'Grandcruwijnen',
            'url': self.allowed_domains[0]
        }
        wine['url'] = response.url
        wine['winery'] = find_property(response, 'Wijnhuis')
        wine['name'] = response.css('h1.product-name::text').get()
        wine['price'] = float_or_none(
            response.css('span[itemprop="price"]::text').get())
        wine['volume'] = float_or_none(
            find_property(response, 'Inhoud fles').split(' ')[0])
        wine['year'] = find_property(response, 'Jaar')

        yield wine
Exemplo n.º 6
0
    def parse_item(self, response):
        """ Creates a VendorWine from the response """
        wine = VendorWine()
        wine["vendor"] = {
            "name": "Henri Bloem",
            "url": self.allowed_domains[0]
        }
        wine["url"] = response.url
        wine["winery"] = find_property(response, "Producent")
        wine["name"] = response.css("#product-specs > h2::text").get()
        wine["price"] = float_or_none(
            response.css("meta[itemprop=\"price\"]::attr(content)").get())
        wine["year"] = find_property(response, "Oogstjaar")
        wine["volume"] = .75

        # update volume if specified in wine name
        m = re.search(pattern, wine["name"])
        if m is not None:
            wine["volume"] = float_or_none(m.group(1).replace(",", "."))

        yield wine
Exemplo n.º 7
0
    def parse_item(self, response):
        """ Creates a VendorWine from the response """
        wine = VendorWine()
        wine['vendor'] = {'name': 'Barts Wijnkoperij', 'url': self.allowed_domains[0]}

        data = response.xpath('//script[@type="application/ld+json" and contains(text(), "Product")]/text()').get()
        d = json.loads(data)

        wine['url'] = d.get('url')
        wine['winery'] = ''
        wine['name'] = d.get('name')
        offers = d.get('offers', [])
        if len(offers) > 0:
            wine['price'] = float_or_none(offers[0]['price'])
        wine['year'] = ''
        wine['volume'] = 0.75

        m = re.search(volume_pattern, d.get('url'))
        if m is not None:
            wine['volume'] = float_or_none(m.group(1)) / 100

        yield wine
Exemplo n.º 8
0
    def parse_item(self, response):
        """ Creates a VendorWine from the response """
        wine = VendorWine()
        wine['vendor'] = {'name': self.name.title(), 'url': self.allowed_domains[0]}
        wine['url'] = response.url
        wine['winery'] = response.css('article::attr(data-ec-brand)').get()
        wine['name'] = response.css('article::attr(data-ec-name)').get()
        wine['price'] = float_or_none(response.css('article::attr(data-ec-price)').get())
        wine['volume'] = 1.5 if 'magnum' in wine['url'] else 0.75
        wine['year'] = 'U.V.'

        m = re.search(year_pattern, wine.get('name'))
        if m is not None:
            wine['year'] = m.group(1)

        yield wine
Exemplo n.º 9
0
    def parse_item(self, response):
        """ Creates a WineVendorsItem from the response """
        wine = VendorWine()
        wine['vendor'] = {
            'name': 'Heeren van de Wijn',
            'url': self.allowed_domains[0]
        }
        wine['url'] = response.url

        wine['winery'] = response.css('#product-info > .details') \
            .xpath('//strong[contains(text(), "Merk:")]/following-sibling::a[1]/text()').get()
        wine['name'] = response.css('strong[itemprop="name"]::text').get()
        wine['price'] = float_or_none(
            response.css('span[itemprop="price"]::text').get().replace(
                ',', '.'))
        wine['year'] = None  # TODO: year is not advertised
        volume = response.css('#product-info > .details') \
            .xpath('//strong[contains(text(), "Inhoud:")]/following-sibling::text()').get().strip()
        wine['volume'] = volumes.get(volume, -1)

        yield wine