Ejemplo n.º 1
0
 def setUp(self):
     '''The test case level setup.'''
     for index, board in enumerate(self.board_list):
         board.set_url(self.BOARD_NAME)
         board.parser = dp.build_parser(dp.PageType.board,
                                        self.page_list[index])
         board.latest_page = self.expect_list[index]['latest_page']
    def setUpClass(cls):
        '''The class level setup.'''
        cls.pages, cls.expects = tests.board_helper.setup()

        cls.parsers = [
            dp.build_parser(dp.PageType.board, board_page)
            for board_page in cls.pages
        ]

        cls.last_page = [
            board_expect['latest_page']
            for board_expect in cls.expects
        ]
Ejemplo n.º 3
0
    def setUpClass(cls):
        '''The class level setup.'''
        cls.path = 'test_path'

        cls.pages, cls.meta, _ = tests.article_helper.setup()
        cls.expects = load_ranged_json(len(cls.pages), 'expect_crawler_')

        cls.contents = {}
        cls.articles = {}
        for index, article_meta in enumerate(cls.meta):
            article_meta = article_meta['article_meta']

            cls.articles[index] = ptt.Article(**article_meta)
            cls.articles[index].parser = dp.build_parser(
                dp.PageType.article,
                cls.pages[index]
            )

            cls.contents[index] = cls.articles[index].parse_content()
Ejemplo n.º 4
0
 def _get_content(self, page):
     '''Transfer HTML content to BeautifulSoup object'''
     with suppress(TypeError):
         self.parser = dp.build_parser(dp.PageType.board, page)
Ejemplo n.º 5
0
 def _get_content(self, page):
     '''Get complete article content.'''
     with suppress(TypeError):
         self.parser = dp.build_parser(dp.PageType.article, page)
Ejemplo n.º 6
0
def retrieve_dom(self, pagetype, page):
    '''A monkey patch for AbstractPage.retrieve_dom.'''
    try:
        self.parser = dp.build_parser(pagetype, page)
    except (KeyError, TypeError):
        raise ValueError
Ejemplo n.º 7
0
 def setUp(self):
     '''The test case level setup.'''
     for index, article in enumerate(self.article_list):
         article.set_url(self.meta_list[index]['article_meta']['href'])
         article.parser = dp.build_parser(dp.PageType.article,
                                          self.page_list[index])
 def setUp(self):
     '''The test case level setup.'''
     self.parsers = [
         dp.build_parser(dp.PageType.article, page)
         for page in self.pages
     ]