파이톤+셀레니움에서 유튜브 광고를 건너뛰는 방법

참조: 비디오 광고(15초 비디오 광고, 30초 비디오 광고, 생략 가능)
비디오를 열 때
  • 몇 초 동안 광고 영상을 재생(건너뛸 수 없음)
  • 몇 초 뒤에'광고 건너뛰기'광고 영상
  • 광고 없음
  • 패턴이 있는 유튜브 애니메이션으로서 본편 애니메이션에서 최대한 스트레스 없이 파이톤+셀레니움으로 화면을 옮기려면 어떻게 해야 좋을까.

    GiitHub에 따라


    우선 GiitHub의adskipper입니다.
    This is a program written in python programming language. It automatically clicks on the 'skip ad' button on the youtube ads. It uses opencv library's Template Matching functionality to do that.
    혹은
        def check_ad(self):
            try:
               self.driver.find_element_by_class_name("videoAdUiPreSkipButton").click()
                self.has_ad = True
                return self.driver.find_element_by_class_name("videoAdUiPreSkipText").text
            except:
                return None
    
        def skip_ad(self):
            try:
                self.has_ad = False
                self.total_skip_ad += 1
                print("已跳過{}個廣告".format(self.total_skip_ad))
                self.driver.find_element_by_class_name("videoAdUiSkipButton").click()
                sleep(1)
                #return self.driver.find_element_by_class_name("videoAdUiSkipButtonExperimentalText").text
            except:
                return None
    

    Stackoverflow


    건너뛰기 버튼을 어떻게 눌러요?
    [How to click the 'skip ads' button in youtube using selenium in python 3](
    selenium-in-python-3)
    원소를 찾을 수 없을 때 어떻게 처리해야 합니까?
    Continue the script if an element is not found using selenium in Python

    간단한 파이썬 예외 처리의 기초


    https://www.atmarkit.co.jp/ait/articles/1909/06/news019.html
    그리고 유한한 재시도는 보기 싫지만 현재의 타협점.
    좋은 걸 찾으면 추가될지도 몰라요.

    좋은 웹페이지 즐겨찾기