ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Selenium 크롬 창 없이 실행, 크롬 드라이버 자동 다운로드
    파이썬/자동화 2021. 7. 12. 23:51

    Selenium 크롬 창 없이 실행하기

      headless옵션을 True로 설정

     

    Selenium 크롬 브라우저 자동으로 최신 버전 다운로드

      webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options) 소스 추가

    1
    2
    3
    4
    5
    6
    7
    8
    9
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from webdriver_manager.chrome import ChromeDriverManager
     
    if __name__ == "__main__":
        options = Options()
        options.headless = True  # 브라우저 자동화 작업을 화면에 표시하지 않게 됨
        driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)  # 최신 크롬 드라이버 설치
        driver.get('https://www.naver.com/')
    cs

     

    댓글

Designed by Tistory.