记录于2021-03-08,OS为阿里云轻量应用服务器CentOS 7.3
错误信息截图
可以通过以下三种方案的任一解决方案解决此问题:
chrome_options.add_argument('--no-sandbox')
sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
chrome_options.add_argument('--disable-dev-shm-usage')
此方案可能会减慢执行速度,但就是它解决了我的问题
正常运行chrome_options:
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(executable_path="/home/admin/test/chromedriver", chrome_options=options)