简体   繁体   中英

How to start headless browser with Selenium on Ubuntu using bash or Python

I'm running a cron job which runs a Python script that uses Selenium. Selenium requires a display, so I've installed Xvfb, started the display, and firefox :

sudo Xvfb :10 -ac
export DISPLAY=:10
firefox

This works when I run these commands in the console, but I want to be able to do it with cron. How can I do this? If I run the virtual display as the main user, will they have access to the virtual display when it's needed by Python script/Selenium?

我建议您使用硒Ghost驱动程序(它正在运行PhantomJS )。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM