예제 #1
0
    def authors(self):
        """Returns the authors names, co-writers or manufacturers for every item.

        >>> authors = wishlist.authors()
        """
        ret = []
        attr = ('de ', 'di ', 'by ', 'von ')
        for author in self.page.xpath("//div[@class='pTitle']"):
            subtree = helpers.tostring(author,
                                       encoding='unicode',
                                       method='html',
                                       pretty_print=True)
            if 'span' in subtree:
                parser = helpers.etree.HTMLParser()
                div = helpers.etree.fromstring(subtree, parser)
                res = div.xpath("//span[@class='small itemByline']//text()")
                for author in res:
                    author = author.replace('~', '').strip()
                    if author.startswith(tuple(attr)):
                        author = author[3:].strip()
                        ret.append(helpers._stripper(author))
                    else:
                        ret.append(helpers._stripper(author))
            else:
                ret.append(ur'')
        dirt = ['DVD', 'VHS']
        for item in dirt:
            while item in ret:
                ret.remove(item)
        return ret
예제 #2
0
    def authors(self):
        """Returns the authors names, co-writers or manufacturers for every item.

        >>> authors = wishlist.authors()
        """
        ret = []
        attr = ('de ', 'di ', 'by ', 'von ')
        for author in self.page.xpath("//div[@class='pTitle']"):
            subtree = helpers.tostring(author, encoding='unicode', method='html', pretty_print=True)
            if 'span' in subtree:
                parser = helpers.etree.HTMLParser()
                div = helpers.etree.fromstring(subtree, parser)
                res = div.xpath("//span[@class='small itemByline']//text()")
                for author in res:
                    author = author.replace('~', '').strip()
                    if author.startswith(tuple(attr)):
                        author = author[3:].strip()
                        ret.append(helpers._stripper(author))
                    else:
                        ret.append(helpers._stripper(author))
            else:
                ret.append(ur'')
        dirt = ['DVD', 'VHS']
        for item in dirt:
            while item in ret:
                ret.remove(item)
        return ret
예제 #3
0
    def prices(self):
        """Returns the price tags for every item in a wishlist.

        >>> prices = wishlist.prices()
        """
        prices = self.page.xpath(
            "//td[@class='pPrice'][not(text()) and not(strong)] | //td[@class='pPrice']/strong[3] | //td[@class='pPrice']/strong[1] | //td[@class='Price']/span/strong//text()"
        )

        # cleanups, every store has different price tag extras
        if 'EUR' in self.currency:
            dust = 'EUR'
        elif 'CDN' in self.currency:
            dust = 'CDN%s' % self.symbol
        elif 'INR' in self.currency:
            dust = 'Rs. '
        elif 'CNY' in self.currency:
            dust = u'\xa5'
        elif 'BRL' in self.currency:
            dust = 'R%s ' % self.symbol
        elif 'JPY' in self.currency:
            dust = u'\x81\x8f'
        else:
            dust = self.symbol

        ret = []
        for price in prices:
            res = helpers.tostring(price,
                                   encoding='unicode',
                                   method='text',
                                   pretty_print=True).strip()
            if 'At' not in res:
                # TODO: how would it work out for non-english stores? quite a huge bug ahead...
                if 'Click' in res:
                    res = ''
                if 'EUR' in self.currency or 'BRL' in self.currency:
                    res = res.replace(dust, '')
                    res = res.replace('.', '')
                    res = res.replace(',', '.')
                else:
                    res = res.replace(dust, '')
                    res = res.replace(',', '')
                ret.append(helpers._stripper(res))
        return ret
예제 #4
0
    def prices(self):
        """Returns the price tags for every item in a wishlist.

        >>> prices = wishlist.prices()
        """
        prices = self.page.xpath("//td[@class='pPrice'][not(text()) and not(strong)] | //td[@class='pPrice']/strong[3] | //td[@class='pPrice']/strong[1] | //td[@class='Price']/span/strong//text()")

        # cleanups, every store has different price tag extras
        if 'EUR' in self.currency:
            dust = 'EUR'
        elif 'CDN' in self.currency:
            dust = 'CDN%s' % self.symbol
        elif 'INR' in self.currency:
            dust = 'Rs. '
        elif 'CNY' in self.currency:
            dust = u'\xa5'
        elif 'BRL' in self.currency:
            dust = 'R%s ' % self.symbol
        elif 'JPY' in self.currency:
            dust = u'\x81\x8f'
        else:
            dust = self.symbol

        ret = []
        for price in prices:
            res = helpers.tostring(price, encoding='unicode', method='text', pretty_print=True).strip()
            if 'At' not in res:
                # TODO: how would it work out for non-english stores? quite a huge bug ahead...
                if 'Click' in res:
                    res = ''
                if 'EUR' in self.currency or 'BRL' in self.currency:
                    res = res.replace(dust, '')
                    res = res.replace('.', '')
                    res = res.replace(',', '.')
                else:
                    res = res.replace(dust, '')
                    res = res.replace(',', '')
                ret.append(helpers._stripper(res))
        return ret