2017 © Pedro Peláez
 

library casperjs-php-driver

An improved general purpose PHP driver for CasperJS

image

workdigital/casperjs-php-driver

An improved general purpose PHP driver for CasperJS

  • Friday, September 29, 2017
  • by jnardiello
  • Repository
  • 27 Watchers
  • 2 Stars
  • 7,119 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 11 Versions
  • 2 % Grown

The README.md

CasperJS PHP Driver

Build status, (*1)

Prerequisites

This driver will assume that the command casperjs is available in your $PATH. If not, you can install it with:, (*2)

npm install -g casperjs

Installation

You can use this package in your project via composer. Add these lines to your composer.json:, (*3)

"require": {
  "workdigital/casperjs-php-driver": "1.*"
},
…

Latest stable release is 1.0, (*4)

Examples

Basic usage

$driver = new CasperJs\Driver();
$output = $driver->start('http://someurl.com')
                 ->run();

Setting request parameters and interacting with the page

The entire point of using a tool like Casper is to be able to properly interact with the DOM for both testing and scraping purposes. This driver tries to expose a friendly interface to do so where you can define both request params and DOM interaction before making the actual call., (*5)

$driver = new CasperJs\Driver();
$driver->start('http://someurl.com')
       ->setUserAgent('AmericanPizzaiolo')
       ->setHeaders([
           'Accept-Language' => ['en-US'],
           'Some-Header' => 'Foo-bar',
       ])
       ->evaluate('make me a pizza')
       ->setViewPort(1024, 768)
       ->waitForSelector('.selector', 30000)
       ->wait(10000)
       ->click('.selector');

$output = $driver->run();

Using a proxy for your call

$driver = new CasperJs\Driver();
$driver->start('http://someurl.com')
       ->useProxy('1.1.1.1');

$output = $driver->run();

Getting the Casper Output

Whenever you execute Driver::run() the Driver will return an Output object that will encapsulate the Casper output. Output will expose the captured casper data or throw an exception in case the desired behaviour wasn't performed (i.e. if a css selector to be present in the page after timeout expired)., (*6)

Extracting Data

$html = $output->getHtml();
$statusCode = $output->getStatusCode();
$currentUrl = $output->getCurrentUrl();

More examples

For more examples check out test/DriverTest.php, (*7)

Credits

This driver is essentially an enhanced and improved version of the original alwex/php-casperjs., (*8)

The Versions

29/09 2017

dev-master

9999999-dev

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

29/09 2017

1.1.5

1.1.5.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

29/09 2017

dev-WD-87-proxy-auth

dev-WD-87-proxy-auth

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

14/03 2017

1.1.4

1.1.4.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

13/02 2017

1.1.3

1.1.3.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

24/08 2016

1.1.2

1.1.2.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

01/07 2016

1.1.1

1.1.1.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

30/06 2016

1.1.0

1.1.0.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

15/12 2015

1.0.2

1.0.2.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

09/11 2015

1.0.1

1.0.1.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry

09/08 2015

1.0

1.0.0.0

An improved general purpose PHP driver for CasperJS

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

by Jacopo Nardiello
by Fabrice Guéry