1. Install and pyvirtualdisplay Xvfb
sudo apt-get install xvfb
pip install pyvirtualdisplay
2. Install chrome, chromedriver and selenium
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
wget https://chromedriver.storage.googleapis.com/75.0.3770.90/chromedriver_linux64.zip
decompression, added to the path in the chromedriver
pip install selenium
to here. Environment has configured. The next can be more than code.
from pyvirtualdisplay import Display from selenium import webdriver display = Display(visible=0, size=(900, 800)) display.start() driver = webdriver.Chrome() driver.get('http://www.umn.edu') print (driver.title)