示例#1
0
    def _get_matches_info(self, match_elements, championship_urls):
        matches = []
        base_len = len(OneXBetScraper._BASE_URL)

        for match_element in list(match_elements)[:]:
            try:
                url = match_element.get_attribute('href')[base_len:]
            except StaleElementReferenceException:
                print('Caught StaleElementReferenceException')
                continue

            if url in championship_urls or match_element.get_attribute(
                    'class') != 'link' or url.endswith('-Special-bets/'):
                continue

            match_title_text = match_element.find_element_by_class_name(
                'gname').text
            match_title = MatchTitle.from_str(match_title_text)
            date_time_str = match_element.find_element_by_class_name(
                'date').text
            try:
                date_time = DateTime.from_1xbet_str(date_time_str)
            except ValueError:
                print(url)
                continue
            match = Match(match_title, self._BASE_URL + url, date_time, self)
            matches.append(match)

        return matches