its actually pretty simple. Using another answer I gave in stack over flow
https://stackoverflow.com/a/21871600/2423379
EDIT: Running Firefox in Headless mode
Requirements:
sudo apt-get install xvfb
(or equivalent command in ur distro)pip install --user xvfbwrapper
And code part
from xvfbwrapper import Xvfb
vdisplay = Xvfb()
vdisplay.start()
# launch stuff inside virtual display here
vdisplay.stop()