A list of headless web browsers
github.com
github.com
I haven't used it myself, but I'm considering it, so I'd appreciate hearing other people's thoughts about it.
[1] https://bitbucket.org/chromiumembedded/cef
[2] https://en.wikipedia.org/wiki/Chromium_Embedded_Framework#Ap...
[3] https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage...
I'm using it for off-screen rendering. It's pretty straightforward, once past the inevitable initial hump. The code is sensible (if a little smart pointer-happy), and you're provided with a good range of hooks. Documentation is OK. Nothing you can't figure out if you've got a debugger...
(I used Visual Studio with the prebuilt Spotify builds. This addin really helps: https://visualstudiogallery.msdn.microsoft.com/a1141bff-463f...)
I first looked at Awesomium because it had a Unity3D interface [1], but that's gone stale (Awesomium doesn't support 64 bits, much has changed in Unity since then, not to mention Chrome itself), and some developers on the Unity discussion groups were suggesting CEF as an alternative. [2] [3]
I'm interested in integrating the latest CEF with the latest Unity3D on Mac and Windows desktop, as well as for consoles.
There are (non-Unity-specific, i.e. maybe too complex and modern) C# wrappers for CEF [4], which looks pretty elaborate, but I think it would be tighter to integrate the CEF C++ code directly as a native Unity extension, without thunking through too much Windows-oriented C# glue that might not be compatible with Unity's older version of C#.
On iOS I'm simply using WkWebKit, and WebKit on Chrome, which both support off-screen rendering.
Here's some interesting stuff comparing Awesomium and CEF and other stuff from Stratoscope. [5] It's from a 446 day old thread about CefSharp [6] so it might predate the Awesomiumocalypse. The thread is interesting reading! Really makes me wonder why Awesomium is on the list at all.
It looks like Coherent UI is a commercially supported alternative to Awesomium, but I haven't looked into it yet. Their employee said good things about CEF and offered some fair criticism:
"Hi, Stoyan from Coherent Labs here. My impressions of CEF are very good. They manage to keep it very close to the chromium HEAD, which is great. The only technical downside of CEF is the imperfect GPU acceleration. In many cases however the architecture of chromium itself is a hindrance. Their processes hog memory like crazy and introduce perceivable lag. We had to write a complete new product to solve the issue for games." [7]
[1] http://labs.awesomium.com/unity3d-integration-tutorial-part-...
[2] http://answers.unity3d.com/questions/945207/unity3d-v5-aweso...
[3] http://gamedev.stackexchange.com/questions/111846/chromium-e...
[4] https://github.com/cefsharp/CefSharp
[5] https://news.ycombinator.com/item?id=10089645
I'm going to add "thought leader".
I spent a long time trying to find an up to date javascript engine in a headless browser a while back before I gave up and just wrote a chrome extension, installed a copy of chromium, and ran the whole thing in xvfb with the extension added by command line.
In the end unless you are severely resource constrained,it is a very good option.
I run firefox/chrome under Xvfb and very frequently get unexplaine `Unable to connect to host 127.0.0.1 on port 7055` from selenium, zombie firefox and chrome processes, and hundreds of TCP ports in status TIME_WAIT.
I've always assumed it had something to do with Xvfb/browser interaction.
To prevent that you need to run the firefox command with "-new-instance" or "-no-remote" (which implies "-new-instance").
Firefox also 'locks' profiles which are in use, so you need to use separate profiles for each Firefox instance which is running. You can do that by making a temporary directory "T" and passing it to the firefox command as "-profile T".
As an example, the Firefox command I'm using in one of my scripts is currently:
timeout 60 firefox -safe-mode \
-profile "$FF_DIR" \
-no-remote \
-new-instance \
"$URL"
XFVB is an X server, which programs connect to based on the "DISPLAY" environment variable. You can see what that's set to by running: echo "$DISPLAY"
You can set it, e.g. to ":99", by doing: export DISPLAY=:99
Each running X server needs a different display number; this includes regular desktop sessions (usually running on Xorg with display :0), XVFB, Xnest, Xephyr, etc.I use a variant of the script at http://stackoverflow.com/a/30336424/884682 to choose an unused display number for each XVFB invocation.
NOTE: This is based on simple automation tasks with bash and xdotool. I don't use Selenium, so I don't know if already does any of this. Hope it helps anyway :)
Handy for more tricky sorts of web scraping, or if you want to use chromium in mobile emulation mode (causing websites with an 'app version' to switch over to a HTTP-JSON SPA in many cases). I was particularly excited to discover you can set the 'http_proxy' env variable on a "per-browser node" basis (and do fun stuff like installing DNS caching daemons, round-robinning through OpenVPN/squid containers etc.).
Even simple tasks like taking a screenshot of a given web page involves PhantomJS, which seems really heavy-handed.
Thanks for compiling this list but the issue I'm having with this is the lack of a rating system based on usage, Github stars, downloads, repo activity, project creation, corporate support, etc. to get a measure of how reliable those tools are.
There is also headless chrome browser in development, not sure if there are any prebuilt binaries out there?
[1] https://bugs.chromium.org/p/chromium/issues/detail?id=546953
I check every now and again. I'm super interested in headless PDF generation (using Nigtmare now)
download support[1] is the only new api in development. it's not tagged for the 2.5 release[2].
[1] https://github.com/ariya/phantomjs/pull/14225 [2] https://github.com/ariya/phantomjs/issues/14458
There has been an open issue for this for three years[1].
I build from chromium src, and my code is more or less an extension with its own BUILD.gn with a deps on //headless. Once you've built the initial tree (took a night for me), builds will be really fast.
Most of the interaction with the browser is by the chrome debugging protocol, as with "normal" chromium. Generally speaking, you want to target that, instead of the internal APIs.
There are some tweaks you need to be aware of. Chromium needs a homedir, so you want to configure that. There's state stored between sessions, so if you want process invocations stateless, consider spending some time hacking or run the process in a fresh namespace/chroot/docker/jail/whatever each time. I had to write my own protocol handler and URLRequestJobs because I render pages from archives on disk and that was the easiest way to get that started at the time.
I don't know if vanilla chromium supports it, but I'm pretty sure I've seen a --headless flag somewhere... If not, headless_shell is pretty easy to build following the official build instructions[1]. I'm running on RHEL/Fedora/CentOS. There's also unofficial images on docker hub if you want to go that route.
[1]: https://chromium.googlesource.com/chromium/src/+/lkgr/headle...
https://bugs.chromium.org/p/chromium/issues/detail?id=546953...
- Start a 'selenium hub'
- Start up as many firefox/chrome 'node' containers and link them to the hub.
- Point webdriver at the hub port and url.
I will eventually get around to building some Alpine containers for this, one day. I find the official ones a bit 'heavy' given all it really invoves in installing openJDK and running a jar file / browser driver.
At the moment I use Ghostinspector (a SaaS) which works okay. Their UI is a bit clunky, but recording stuff via Chrome extension and modifying it later works okay. Also they let me run the tests with Firefox later. So I develop with Chrome and run tests with Firefox.
"The product is very well alive. Version 1.7.6 will be released in a few days with many new features and an updated Unity plugin as well. Meanwhile, we are also working on our next major version (v2.0)." Perikles C. Stephanidis, Jun 15
The other big problem is that it's not free. So nobody is going to pick it up and run with it.
[1] http://answers.awesomium.com/questions/6880/does-the-project...
[2] http://answers.awesomium.com/questions/7255/is-awesomium-dea...