📌  相关文章
📜  selenium 不打开浏览器窗口 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:13.644000             🧑  作者: Mango

代码示例1
# credit to the Stack Overflow user in the source link

sudo apt-get install xvfb
pip install pyvirtualdisplay

#!/usr/bin/env python
from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(800, 600))
display.start()

# Now Firefox will run in a virtual display.
# You will not see the browser.
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print(browser.title)
browser.quit()
display.stop()