snapshot-selenium
snapshot-selenium copied to clipboard
在docker容器中渲染图片遇到问题
我将程序部署在服务器后,发现运行make_snapshot提示:DevToolsActivePort file doesn't exist。 通过分析发现,在docker容器root权限下,chrome无法运行,需要在使用selenium调用chromedriver时为其添加参数”—no-sandbox”。 建议在get_chrome_driver函数在添加“—headless”参数的同时,加上上述参数。或者,为get_chrome_driver函数添加关键字参数,让使用者可以自行添加参数。
我将程序部署在服务器后,发现运行make_snapshot提示:DevToolsActivePort file doesn't exist。 通过分析发现,在docker容器root权限下,chrome无法运行,需要在使用selenium调用chromedriver时为其添加参数”—no-sandbox”。 建议在get_chrome_driver函数在添加“—headless”参数的同时,加上上述参数。或者,为get_chrome_driver函数添加关键字参数,让使用者可以自行添加参数。
在snapshot.py里面设置吗?为什么我设置了还是不行……
我将程序部署在服务器后,发现运行make_snapshot提示:DevToolsActivePort file doesn't exist。 通过分析发现,在docker容器root权限下,chrome无法运行,需要在使用selenium调用chromedriver时为其添加参数”—no-sandbox”。 建议在get_chrome_driver函数在添加“—headless”参数的同时,加上上述参数。或者,为get_chrome_driver函数添加关键字参数,让使用者可以自行添加参数。
解决了,本地的没有同步到服务器,也是醉了。 def get_chrome_driver(): options = webdriver.ChromeOptions() options.add_argument("headless") options.add_argument('no-sandbox') return webdriver.Chrome(options=options) 改为这样即可
对,没有 X window sever 的话, headless 是必须的