Yuval Cohen Yuval Cohen - 1 year ago 144
Python Question

Opening pages asynchronously in headless browser (PhantomJS)

I am using PhantomJS via Python through Selenium+Ghostdriver.

I am looking to load several pages simultaneously and to do so, I am looking for an async method to load pages.

From my research, PhantomJS already lives in a separate thread and supports multiple tabs, so I believe the only missing piece of the puzzle is a method to load pages in a non-blocking way.

Any solution would be welcome, be it a simple Ghostdriver method I overlooked, bypassing Ghostdriver and interfacing directly with PhantomJS or a different headless browser.

Thanks for the help and suggestions.


Answer Source

If you want to bypass ghostdriver, then you can directly write your PhantomJS scripts in JavaScript or CoffeeScript. As far as I know there is no way of doing this with the selenium webdriver except with different threads in the language of your choice (python).

If you are not happy with it, there is CasperJS which has more freedom in writing scripts than with selenium, but you will only be able to use PhantomJS or SlimerJS.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download