3

Linux服务器使用selenium的正确知识

 2 years ago
source link: https://gargantuax.github.io/blog/2017-08/linux%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%BD%BF%E7%94%A8selenium%E7%9A%84%E6%AD%A3%E7%A1%AE%E7%9F%A5%E8%AF%86/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Linux服务器使用selenium的正确知识 | GargantuaX
Linux服务器使用selenium的正确知识
  • Aug 30, 2017
  • One minute read

最近使用PHP做了一些爬虫,其中部分需要用到selenium开浏览器

值得注意的是Linux服务器没有显示输出终端的,我们要运行GUI程序,需要用到虚拟显示终端,比如 Xvfb

另外服务器上建议用Firefox,备用Chrome,在实践当中,前者问题少一些

安装php-webdriver

https://github.com/facebook/php-webdriver

安装Firefox

apt-get install firefox

安装geckodriver

https://github.com/mozilla/geckodriver/releases

安装xvfb

apt-get install xvfb

设置xvfb

export DISPLAY=:10

Xvfb :10 -screen 0 1366x768x24 -ac &

启用selenium.jar

nohup java -jar selenium-server-standalone-#.jar &

现在可以使用webdriver控制selenium了


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK