ponty / PyVirtualDisplay

Python wrapper for Xvfb, Xephyr and Xvnc
BSD 2-Clause "Simplified" License
714 stars 78 forks source link

Purpose of PyVirtualDisplay #58

Closed shawnngtq closed 2 years ago

shawnngtq commented 3 years ago

I read online and happen to come across this library and selenium. I am curious to understand what is the purpose of this library?

Based on what I read, I thought we can still continue to scrape data using selenium, without this python wrapper for virtual display? (https://selenium-python.readthedocs.io/getting-started.html)

I wasn't able to find a good documentation to explain this. Can anyone enlighten me? I am not expert in either libraries. Thanks!

ponty commented 3 years ago

You find the answer in the README: "pyvirtualdisplay is a python wrapper for Xvfb, Xephyr and Xvnc"

I'dont know Selenium but you can ask your questions about it in the Selenium project forum.

DobroAlex commented 3 years ago

@shawnngtq , it' really simple. I have a project where I need to visit some urls, take screenshots and recognize text using Tesseract. The first option is to take a screenshot of an arbitrary size is to run chrome headless. On the other hand, any decent anti bot system will block a headless browser on sight. The other solution is to run a headfull browser. The problem here is that it requires some window manager and you can't simply install Gnome and expect Chrome to launch if you're using SSH as SSH "doesn't see" (a poor choice of words) any displays. So I'm using this lib to create a big sized xvfb and an arbitrary sized Chrome.

@ponty , I'm appreciating your job a lot. This package really saves a lot of time for someone who works with browsers and anti bot systems

shawnngtq commented 3 years ago

@DobroAlex You can run headless selenium, but some website would block these. With pyvirtualdisplay, if visible=False, even though it looks headless, but the selenium that runs within it is not headless, therefore wouldn't be block. Is my understanding correct? 😄

mals14 commented 3 years ago

Is my understanding correct?

That would indeed be useful to know. Although, I think there are websites that can tell that it is controlled selenium visiting even when selenium is not running headless.

FernandoRD commented 3 years ago

Hi, I have a question, don´t know if here is the right to place to ask... I want to know if PyVirtualDisplay can work together with wfreerdp (https://github.com/FreeRDP/FreeRDP/wiki/PreBuilds) My need is to build a sensor in Nagios that tries to connect to a windows server to verify if the RDP service is OK. There are sensors to do it, but they only test if the server accepts the connection. In my case the problem is that the server accepts it but the screen doesn´t load properly... It will have to run headless.... thankyou.

ponty commented 3 years ago

Xvfb is for X display server, not for Windows. PyVirtualDisplay only starts Xvfb in headless mode.

https://en.wikipedia.org/wiki/Xvfb