Browse Source

Update 'README.md'

天问 10 months ago
parent
commit
4365e6dc2c
1 changed files with 34 additions and 0 deletions
  1. 34 0
      README.md

+ 34 - 0
README.md

@@ -1,2 +1,36 @@
 # PyVirtualDisplay
 
+在内存中创建虚拟显示,基于 xvfb (X Virtual FrameBuffer)的一个轻量级包装
+
+
+```
+pip install pyvirtualdisplay
+sudo apt-get install xvfb
+
+
+from pyvirtualdisplay import Display
+from selenium import webdriver
+
+# 创建一个虚拟显示
+display = Display(visible=0, size=(800, 600))
+display.start()
+
+# 在虚拟显示上启动浏览器
+browser = webdriver.Firefox()
+browser.get('http://www.google.com')
+print(browser.title)
+browser.quit()
+
+# 停止虚拟显示
+display.stop()
+
+```
+
+## Reference
+
+[ponty/PyVirtualDisplay](https://github.com/ponty/PyVirtualDisplay)
+
+
+
+
+