dummy-link

HeadlessChromium

Julia wrapper of the Chromium web browser

Readme

HeadlessChromium

A Julia wrapper for Chromium

Julia versions master build Coverage
HeadlessChromium Build Status Build status Coverage Status

This package is a Julia wrapper for the Google Chromium web browser. The Browser is launched headless and is controlled from Julia over the 'Chrome DevTools Protocol'. The DOM can be explored, changed, captured to a pdf document, input events can be simulated, etc.

Use this package to :

  • scrape web sites, automate form filling
  • test web applications
  • capture screenshots

For a full documentation of the DevTools Protocol see : https://chromedevtools.github.io/devtools-protocol/tot

Opening a new page (a 'target'):

using HeadlessChromium

myTarget = Target("about:") # open the 'about:' page

Opening a new page, this time providing a callback function to capture events emitted.:

mycallback(resp) = info(resp, prefix="event : ") # will be called for each event

myTarget2 = Target("http://www.yahoo.com", mycallback)

Sending a command to the page and waiting for the result:

resp = send(myTarget, "Browser.getVersion")
# resp is a dictionary representation of the JSON returned by Chromium

The synchronous version of send accepts a timeout keyword argument (default=5) specifying the number of seconds to wait before throwing a TimeoutException.

Sending a command to the page asynchronously (i.e. without waiting for Chromium to respond):

plotfile = tempname() # output file
send(myTarget, "Page.printToPDF", format="A4") do resp
    open(plotfile, "w") do io
        write(io, base64decode(resp["result"]["data"]))
    end
end

Closing the target:

close(myTarget)

Closing Chromium (will be relaunched automatically on the next Target() call):

stopChromium()

First Commit

10/20/2017

Last Touched

6 months ago

Commits

23 commits

Used By: