Python 是否有与PyVirtualDisplay等效的Windows

Python 是否有与PyVirtualDisplay等效的Windows,python,selenium,pyvirtualdisplay,Python,Selenium,Pyvirtualdisplay,我为一位同事写了一个网页刮板,以节省他的工作时间。它是用Python编写的,使用Selenium并打开Firefox浏览器 我自己在使用PyVirtualDisplay的Linux机器上编写了这段代码,因此Firefox实际上不会打开并干扰我的工作 如何使其在Windows PC上的虚拟显示器中运行?无法在Windows上运行PyVirtualDisplay的原因是PyVirtualDisplay使用Xvfb作为显示器,而Xvfb是X Window系统的无头显示服务器,Windows不使用X W

我为一位同事写了一个网页刮板,以节省他的工作时间。它是用
Python
编写的,使用
Selenium
并打开Firefox浏览器

我自己在使用
PyVirtualDisplay
的Linux机器上编写了这段代码,因此Firefox实际上不会打开并干扰我的工作


如何使其在Windows PC上的虚拟显示器中运行?

无法在Windows上运行
PyVirtualDisplay
的原因是PyVirtualDisplay使用Xvfb作为显示器,而Xvfb是X Window系统的无头显示服务器,Windows不使用X Window系统

不推荐使用

所以。。。如果您坚持使用PyVirtualDisplay,您可以做的是更改
显示(visible=True)
,或者您可以设置后端,如API中所示

我的推荐

不要使用
PyVirtualDisplay
您可以使用任何Web驱动程序,如Chrome驱动程序,只需使用
--headless
添加ChromeOptions即可

或者在您的情况下,您使用firefox,使其看起来像:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument("--headless")
driver = webdriver.Firefox(firefox_options=options, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
print("Firefox Headless Browser Invoked")
driver.get('http://google.com/')
driver.quit()
欲了解更多更新信息,请查看


希望这对你有帮助

您是否找到了在Windows PC上进行虚拟显示的解决方案?(不使用
——无头