Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Headless Browser? [closed]

Is there a headless browser library for PHP? Would like something that has a JS engine built into it. FOSS preferred.

like image 606
StackOverflowNewbie Avatar asked Jul 05 '11 05:07

StackOverflowNewbie


People also ask

Can headless browser be detected?

There are many ways to detect whether a request is coming from a headless browser, but whether it will be easy to do so depends greatly on how the headless browser is configured. If used for web scraping, hackers do their absolute best to obscure detection.

How do I open my browser 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.

Is headless scraping faster?

Headless Browsers are Faster than Real Browsers But you will typically see a 2x to 15x faster performance when using a headless browser.

What is happening when the browser is running in headless mode?

You heard it right, it is called “headless”), it means a browser without a user interface or “head.” So, when the browser is headless, the GUI is hidden. Therefore, when you use a headless browser to access any website, you can't see anything. However, the program runs in the background.


2 Answers

PhantomJS - http://phantomjs.org/

PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

You can couple it with something like php-PhantomjsRunner (now deprecated) if you want or bake your own.

When setup and ready to start testing with PhantomJS, pick out one of the various Testing Frameworks at your disposal.

I recently also came across this tutorial from tutsplus should it help anyone.

like image 174
Anthony Hatzopoulos Avatar answered Oct 17 '22 15:10

Anthony Hatzopoulos


Check out mink and it's support for zombie as a back-end.

It looks quite good, and appears to be well supported.


Edit:

Unfortunately, php has no native javascript interpreter; so if you are looking for a pure php implementation including javascript support, currently, you will not find it. For headless with javascript support, you will have to rely on something like node.js or phantomjs on the back-end.

I'm sure you've seen them already, but for other options that are either headed or lack javascript support, Mink's other backends are worth perusing.

like image 8
David Avatar answered Oct 17 '22 16:10

David