def __convert_to_ebook(self, book): ebook = Ebook() ebook.title = book.get('name', '') ebook.price = book.get('price', 0.0) ebook.cover = book.get('cover', '') return ebook
def __convert_to_ebook(self, book): ebook = Ebook() ebook.title = book.get('title', '') ebook.author = self.__get_author(book) ebook.price = book.get('salesPrice', 0.0) / 100.0 ebook.cover = book.get('cover', '') ebook.intro = book.get('abstract', '') return ebook
def __convert_to_ebook(self, book): ebook = Ebook() ebook.title = book.find('.title').text() ebook.author = book.find('.u-author').text() ebook.price = float( book.find('.u-price em').text().replace('¥', '').strip()) ebook.cover = book.find('.cover img').attr('src') ebook.intro = book.find('.desc').text() return ebook
def __convert_to_ebook(self, book): row = PyQuery(book.find('div.sg-row')[1]) image_wrap = PyQuery(row.children()[0]) info_wrap = PyQuery(row.children()[1]).find('.sg-row') title_author_wrap = PyQuery(info_wrap[0]) price_wrap = PyQuery(info_wrap[1]) price = price_wrap.find('.a-price-whole').text() + \ price_wrap.find('.a-price-fraction').text() ebook = Ebook() ebook.title = title_author_wrap.find('h2').text() ebook.author = title_author_wrap.find('h2')\ .next().text().split('|')[0].strip() ebook.price = book.find('.u-price em').text() ebook.cover = image_wrap\ .find('[data-component-type="s-product-image"] img')\ .attr('src') ebook.price = float(price) return ebook
def __convert_to_ebook(self, book, prices): sku_id = self.__get_sku_id(book) image = book.find('.p-img img') ebook = Ebook() ebook.title = book.find('.p-name').text() ebook.author = book.find('.p-bi-name a[title]').text() ebook.price = prices.get(sku_id, 0.0) ebook.cover = image.attr('src') or image.attr('data-lazy-img') return ebook
def __convert_to_ebook(self, book): book_info = book.get('bookInfo') if book_info.get('format') != 'epub' or book_info.get('soldout') == 1: return None ebook = Ebook() ebook.title = book_info.get('title', '') ebook.author = book_info.get('author', '') ebook.price = book_info.get('price', 0.0) ebook.cover = book_info.get('cover', '') ebook.intro = book_info.get('intro', '') return ebook