Exemplo n.º 1
0
    def _tanfuku_common(
        self, target_date: date, jyo_cd: int, race_no: int, num: int, kake: str
    ) -> list:
        """
        # 2 3連単,3連複共通部分を関数化

        Parameters
        ---------
            num: int
                2 or 3
            kake : str
                rentan or renfuku

        Returns
        -------
            odds_matrix : list
                oddsのリスト(htmlのテーブルと同配列)
                要素は少数型
        """
        assert kake in ["rentan", "renfuku"]
        assert num in [2, 3]
        # num = 2ならtypeによらずtype='tf'
        if num == 2:
            html_type = "tf"
        elif kake == "rentan":
            html_type = "t"
        elif kake == "renfuku":
            html_type = "f"
        else:
            html_type = "tf"

        # htmlをload
        target_url = (
            f"https://boatrace.jp/owpc/pc/race/odds{num}{html_type}?"
            f"rno={race_no}&"
            f"jcd={jyo_cd:02}&hd={target_date.strftime('%Y%m%d')}"
        )
        lx_content = GetParserContent.url_to_content(
            url=target_url, content_type="lxml"
        )
        # 3連単と共通--------------------
        # oddsテーブルの抜き出し
        if num == 2 and kake == "renfuku":
            table_xpath = (
                "/html/body/main/div/div/div/div[2]/div[8]/table/tbody"
            )
        else:
            table_xpath = (
                "/html/body/main/div/div/div/div[2]/div[6]/table/tbody"
            )

        # 横優先のoddsリスト
        odds_el = lx_content.xpath(
            "/".join([table_xpath, "tr/td[contains(@class, 'oddsPoint')]"])
        )
        odds_horizontals = list(
            map(lambda x: self._check_ketsujyo(x.text), odds_el)
        )

        return odds_horizontals
Exemplo n.º 2
0
 def _raceinfo(self, target_date: date, jyo_cd: int,
               race_no: int) -> ResultInfo:
     target_url = (f"http://boatrace.jp/owpc/pc/race/raceresult?"
                   f"rno={race_no}&"
                   f"jcd={jyo_cd:02}&"
                   f"hd={target_date.strftime('%Y%m%d')}")
     self.logger.debug(f"Get result from {target_url}.")
     lx_content = GetParserContent.url_to_content(url=target_url,
                                                  content_type="lxml")
     common = self._commoninfo(lx_content)
     players = list(self._playerinfo(lx_content))
     self.logger.debug("Completed.")
     return ResultInfo(target_date, jyo_cd, race_no, common, players)
Exemplo n.º 3
0
    def _raceinfo(self, target_date: date, jyo_cd: int,
                  race_no: int) -> ChokuzenInfo:
        target_url = (f"https://boatrace.jp/owpc/pc/race/beforeinfo?"
                      f"rno={race_no}&"
                      f"jcd={jyo_cd:02}&"
                      f"hd={target_date.strftime('%Y%m%d')}")
        self.logger.debug(f"get html: {target_url}")
        lx_content = GetParserContent.url_to_content(url=target_url,
                                                     content_type="lxml")

        # common
        common = self._commoninfo(lx_content)
        players = list(self._playersinfo(lx_content))
        return ChokuzenInfo(target_date, jyo_cd, race_no, common, players)
Exemplo n.º 4
0
    def _raceinfo(
        self, target_date: date, jyo_cd: int, race_no: int
    ) -> ProgramInfo:
        # htmlをload
        target_url = (
            f"https://boatrace.jp/owpc/pc/race/racelist"
            f"?rno={race_no}"
            f"&jcd={jyo_cd:02}"
            f"&hd={target_date.strftime('%Y%m%d')}"
        )
        self.logger.debug(f"get html: {target_url}")
        lx_content = GetParserContent.url_to_content(
            url=target_url, content_type="lxml"
        )
        self.logger.debug("get html completed.")
        common = self._commoninfo(lx_content)
        players = list(self._playersinfo(lx_content))

        return ProgramInfo(target_date, jyo_cd, race_no, common, players)
Exemplo n.º 5
0
    def _tansho(self, target_date: date, jyo_cd: int, race_no: int) -> Tansho:
        # htmlをload
        target_url = (
            f"https://boatrace.jp/owpc/pc/race/oddstf?"
            f"rno={race_no}&"
            f"jcd={jyo_cd:02}&"
            f"hd={target_date.strftime('%Y%m%d')}"
        )
        lx_content = GetParserContent.url_to_content(
            url=target_url, content_type="lxml"
        )
        target_xpath = (
            "/html/body/main/div/div/div/div[2]"
            "/div[5]/div[1]/div[2]/table/tbody/"
            "tr/td[contains(@class, 'oddsPoint')]"
        )

        odds_els = lx_content.xpath(target_xpath)
        odds_list = list(map(lambda x: self._check_ketsujyo(x.text), odds_els))

        content_dict = {}
        for key_name in Tansho.__annotations__.keys():
            content_dict[key_name] = odds_list.pop(0)
        return Tansho(**content_dict)