Ubuntu 14.04
sudo apt-get install python-pip sudo apt-get install xvfb xserver-xephyr vnc4server sudo pip install pyvirtualdisplay # 可选 sudo apt-get install python-pil scrot sudo pip install pyscreenshot # optional for examples sudo pip install entrypoint2
测试程序
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox(executable_path=r‘/usr/bin/firefox‘)
browser.get(‘https://www.baidu.com‘)
print browser.title
browser.quit()
display.stop()
输出
百度一下,你就知道
PyVirtualDisplay官方文档https://pypi.python.org/pypi/PyVirtualDisplay
时间: 2024-10-20 03:06:37