byjg/pgbrowser

There is no license information available for the latest version (1.0.0) of this package.

A 'pretty good' mechanize-like php library for managing cookies and submitting forms. [Fork: Totally rewrite]

Maintainers

Details

github.com/byjg/pgbrowser

Source

Installs: 33 686

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 0

1.0.0 2016-05-06 20:32 UTC

This package is auto-updated.

Last update: 2024-04-18 16:58:43 UTC


README

A 'pretty good' mechanize-like php library for managing cookies and submitting forms. [Fork Version]. This fork version was totally refactored for PSR-0 full compliant and was implemented the persistence of cookies between connection in the same session instance (good for crawling)

Read the Documentation

require 'vendor\autoload.php'

$b = new \PGuardiario\PGBrowser();
$page = $b->get('http://www.google.com/');
$form = $page->form();
$form->set('q', 'foo');
$page = $form->submit();
echo $page->title;

Now do something with $page->html or query it with $page->xpath->query()

PGBrowser will also let you query the page with phpquery, simple-html-dom, advanced-html-dom or xpath:

require 'vendor\autoload.php';

$browser = new \PGuardiario\PGBrowser(\PGuardario\PGBrowser::PHPQUERY);
$page = $browser->get('http://www.google.com/search?q=php');
foreach($page->search('li.g') as $li){
  echo $li->at('a')->text . "\n";
}

New - PGBrowser can now cache requests to disk and reuse them on subsequent requests to save network traffic. Cached responses go into a folder called 'cache'

$browser->useCache = true; // turn on cacheing
$browser->useCache = false; // turn off cacheing