Beispiel #1
0
 def getTeamElems(self, homeAway, selector):
     try:
         fullSelector = getSelector(homeAway) + " " + getSelector(selector)
         return self.driver.find_elements_by_css_selector(fullSelector)
     except NoSuchElementException:
         return []
Beispiel #2
0
                    "20210302", "%Y%m%d"
            ) <= targetDate and targetDate <= datetime.datetime.strptime(
                    "20210325", "%Y%m%d"):
                targetDateInfo = getOpen2021(targetDate.strftime("%m%d"))
                driver.get(
                    getConfig("gameTopUrl").replace(
                        "[dateGameNo]", "20210000" + targetDateInfo[gameCnt]))
            else:
                driver.get(
                    getConfig("gameTopUrl").replace("[dateGameNo]",
                                                    pathDate + gameNo))

            commonWait()

            gameState = driver.find_element_by_css_selector(
                getSelector("gameState")).text
            isFinished = gameState in ["試合終了", "試合中止", "ノーゲーム"]

            # 指定試合の[出場成績]画面へ遷移
            # driver.get(getConfig("gameStatsUrl").replace("[dateGameNo]", targetDate.strftime("%Y%m%d") + gameNo))
            if datetime.datetime.strptime(
                    "20210302", "%Y%m%d"
            ) <= targetDate and targetDate <= datetime.datetime.strptime(
                    "20210325", "%Y%m%d"):
                targetDateInfo = getOpen2021(targetDate.strftime("%m%d"))
                driver.get(
                    getConfig("gameStatsUrl").replace(
                        "[dateGameNo]", "20210000" + targetDateInfo[gameCnt]))
            else:
                driver.get(
                    getConfig("gameStatsUrl").replace("[dateGameNo]",
Beispiel #3
0
 def getElems(self, selector):
     try:
         return self.driver.find_elements_by_css_selector(
             getSelector(selector))
     except NoSuchElementException:
         return []
Beispiel #4
0
 def getText(self, selector):
     try:
         return self.driver.find_element_by_css_selector(
             getSelector(selector)).text
     except NoSuchElementException:
         return ""
Beispiel #5
0
            if args.exclude:
                if gameNo in args.exclude:
                    continue
            # ゲーム番号再生成
            gameNo = "0" + gameNo

            # 指定試合の[トップ]画面へ遷移
            # driver.get(getConfig("gameTopUrl").replace("[dateGameNo]", targetDate.strftime("%Y%m%d") + gameNo))
            if datetime.datetime.strptime("20210302", "%Y%m%d") <= targetDate and targetDate <= datetime.datetime.strptime("20210325", "%Y%m%d"):
                targetDateInfo = getOpen2021(targetDate.strftime("%m%d"))
                driver.get(getConfig("gameTopUrl").replace("[dateGameNo]", "20210000" + targetDateInfo[gameCnt]))
            else:
                driver.get(getConfig("gameTopUrl").replace("[dateGameNo]", pathDate + gameNo))
            commonWait()

            gameState = driver.find_element_by_css_selector(getSelector("gameState")).text
            isFinished = gameState in ["試合終了", "試合中止", "ノーゲーム"]

            # 指定試合の[テキスト速報]画面へ遷移
            # driver.get(getConfig("gameTextUrl").replace("[dateGameNo]", targetDate.strftime("%Y%m%d") + gameNo))
            if datetime.datetime.strptime("20210302", "%Y%m%d") <= targetDate and targetDate <= datetime.datetime.strptime("20210325", "%Y%m%d"):
                targetDateInfo = getOpen2021(targetDate.strftime("%m%d"))
                driver.get(getConfig("gameTextUrl").replace("[dateGameNo]", "20210000" + targetDateInfo[gameCnt]))
            else:
                driver.get(getConfig("gameTextUrl").replace("[dateGameNo]", pathDate + gameNo))
            commonWait()
            # 範囲限定
            contentMain = driver.find_element_by_css_selector("#text_live")
            util = Util(contentMain)

            data = []
Beispiel #6
0
                    homeStartPitcherPast = util.getText("homeStartPitcherPast")

                    awayInfo = { "team": away, "pitcher": awayStartPitcherPast }
                    homeInfo = { "team": home, "pitcher": homeStartPitcherPast }

                    data = { "start": startTime, "away": awayInfo, "home": homeInfo }
                    # save as json
                    with open("{0}/{1}.json".format(fullPathDate, gameNo), 'w') as f:
                        json.dump(data, f, indent=2, ensure_ascii=False)
                    print("----- [done] date: {0}, gameNo: {1}, {2} vs {3} -----".format(pathDate, gameNo, away, home))

            except NoSuchElementException as e:
                gameTitleSpanArray = []
                # 試合中止時
                try:
                    gameTitleSpan = driver.find_element_by_css_selector(getSelector("gameTitleSpan")).text
                    gameTitleSpanArray = gameTitleSpan.split(" ")
                except:
                    print("----- not found game gameNo: {0}, page: {1} -----".format(gameNo, gameNoStr))
                    continue

                away = getTeamInitial(gameTitleSpanArray[2])
                home = getTeamInitial(gameTitleSpanArray[0])

                data = { "start": startTime, "away": { "team": away }, "home": { "team": home } }
                # save as json
                with open("{0}/{1}.json".format(fullPathDate, gameNo), 'w') as f:
                    json.dump(data, f, indent=2, ensure_ascii=False)
                print("----- [pending game] date: {0}, gameNo: {1}, {2} vs {3} -----".format(pathDate, gameNo, away, home))

        targetDate = targetDate + datetime.timedelta(days=1)
Beispiel #7
0
def getInningSelector(inning, topBtm):
    topBtmDic = {"表": 1, "裏": 2}
    return getSelector("inningBase").format(topBtmDic[topBtm], inning + 1)