我正在尝试使用aws lambda运行无头铬,我有3层;无头铬69,chromedriver2.44和硒3.14
这是我的代码
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
path = '/tmp/'
def lambda_handler():
try:
options = Options()
options.binary_location = "/opt/python/headless-chromium"
options.headless = True
browser = webdriver.Chrome(options=options, executable_path="/opt/python/chromedriver")
browser.get('http://www.google.com')
return browser.title
except Exception as e:
print(e)
从AWS控制台进行测试会给我这个错误
Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /opt/python/headless-chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.14.133-97.112.amzn2.x86_64 x86_64)