def parse_book(self, book_id): self.fetch() uid = '{}-{}'.format(self.NAME, book_id) els = self.dom.select('h1 > strong') if not els: els = self.dom.select('h2 > b') if els: title = els[0].get_text() else: title = 'Unknown' book = Book(uid, title, lang='zh') for el in self.dom.select('td'): text = el.get_text() m = META_PATTERN.findall(text) if m: group = m[0] book.author = group[0].strip() book.pubdate = group[1].strip() for item in self._parse_book_chapters(): if isinstance(item, Section): book.add_section(item) else: book.chapters.append(item) return book
def parse_book(self, book_id): self.fetch() uid = '{}-{}'.format(self.NAME, book_id) el = self.dom.find('h1') title = el.get_text() book = Book(uid, title, lang='zh') els = self.dom.select('div#smallcons a') if els: el = els[0] author = el.get_text() book.author = author for item in self._parse_book_chapters(): if isinstance(item, Section): book.add_section(item) else: book.chapters.append(item) return book