我需要在Node.js中使用无头Selenium进行抓取。我试过Webdriver.io,它可以处理无头Selenium。但是当我运行无头Selenium时,它根本不起作用。以下是代码(与webdriver.io示例相同)
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end();如何让它与无头硒一起工作?或者还有其他选择吗?
发布于 2017-01-27 18:15:01
您必须在无头环境中设置selenium。试试xvfb --这是火狐的无头gui。
$ apt-get install fvfb -y
$ DISPLAY=:1 xvfb-run java -Dwebdriver.gecko.driver=./geckodriver -jar selenium-server-standalone-3.0.1.jarhttps://stackoverflow.com/questions/39536086
复制相似问题