Use selenium with chromedriver on Mac

后端 未结 4 1084
后悔当初
后悔当初 2021-01-31 06:30

I want to use selenium with chromedriver on Mac,but I have some troubles on it.

  1. I download the chromedriver from ChromeDriver - WebDriver for Chrome
  2. But I
4条回答
  •  感情败类
    2021-01-31 06:59

    For sake of simplicity:

    Download the chrome webdriver from this link. Copy the 'chromedriver' in the folder of python script.

    from selenium import webdriver
    import os
    
    url = 'http://www.webscrapingfordatascience.com/complexjavascript/'
    
    PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
    DRIVER_BIN = os.path.join(PROJECT_ROOT, "chromedriver")
    
    driver = webdriver.Chrome(executable_path = DRIVER_BIN)
    
    driver.get(url)
    
    input('Press ENTER to close the automated browser')
    
    driver.quit()
    

提交回复
热议问题