目前環境為:uat
./chromeDriver/linux/chromedriver
Traceback (most recent call last):
File "web_scraping_start.py", line 24, in <module>
File "main.py", line 124, in main
File "main.py", line 52, in scan_seeds
File "utils/fn_get_web_driver.py", line 37, in fn_get_web_driver
File "selenium/webdriver/chrome/webdriver.py", line 81, in __init__
File "selenium/webdriver/remote/webdriver.py", line 157, in __init__
File "selenium/webdriver/remote/webdriver.py", line 252, in start_session
File "selenium/webdriver/remote/webdriver.py", line 321, in execute
File "selenium/webdriver/remote/errorhandler.py", line 242, in check_response
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
解法:
options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
// shell
sudo chmod 777 ./chrome
// 用sudo執行
sudo ./web_scraping_start uat