Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a headless Chrome instance in Python

This question describes my conclusion after researching available options for creating a headless Chrome instance in Python and asks for confirmation or resources that describe a 'better way'.

From what I've seen it seems that the quickest way to get started with a headless instance of Chrome in a Python application is to use CEF (http://code.google.com/p/chromiumembedded/) with CEFPython (http://code.google.com/p/cefpython/). CEFPython seems premature though, so using it would likely mean further customization before I'm able to load a headless Chrome instance that loads web pages (and required files), resolves a completed DOM and then lets me run arbitrary JS against it from Python.

Have I missed any other projects that are more mature or would make this easier for me?

like image 253
Trindaz Avatar asked Mar 19 '12 19:03

Trindaz


People also ask

What is a headless browser Python?

What is a headless browser? A headless browser can access any website but unlike normal browsers (which you currently use) nothing will appear on the screen. Everything is done on the backend side invisible to the user.

How do I run Chrome in headless mode?

Which command starts the google chrome web browser in headless mode? As we have already seen, you just have to add the flag –headless when you launch the browser to be in headless mode. With CLI (Command Line Interface), just write: chrome \<br> – headless \ # Runs Chrome in headless mode.

How do I run Selenium headless in Chrome?

You can run Google Chrome in headless mode simply by setting the headless property of the chromeOptions object to True. Or, you can use the add_argument() method of the chromeOptions object to add the –headless command-line argument to run Google Chrome in headless mode using the Selenium Chrome web driver.


1 Answers

Any reason you haven't considered Selenium with the Chrome Driver?

http://code.google.com/p/selenium/wiki/ChromeDriver

http://code.google.com/p/selenium/wiki/PythonBindings

like image 113
jdi Avatar answered Sep 29 '22 10:09

jdi