Exemplo n.º 1
0
    def crawling(self):
        self.book = Book()  # Reinitialize Book object for retry
        log.info("Crawling function is call")
        if self.root_url:
            thumb, title, author, chapter_params = self.get_general_info()

            if Book.general_validate(title, author, chapter_params):
                self.book.set_thumb(thumb)
                self.book.set_title(title)
                self.book.set_author(author)
                for chapter_param in chapter_params:
                    chapter = self.get_chapter(chapter_param)
                    if not Book.chapter_validate(chapter):
                        log.error("Chapter: %s is fail crawled", chapter)
                        return False
                    self.book.add_chapter(chapter)

                self.status = True
                return True
            else:
                log.error("No validate general info")
                return False
        else:
            log.error("not define root url")
            return False