pguardiario/pgbrowser

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

A 'pretty good' mechanize-like php library for managing cookies and submitting forms.

This package's canonical repository appears to be gone and the package has been frozen as a result.

dev-master 2017-03-23 03:06 UTC

This package is not auto-updated.

Last update: 2023-01-30 23:59:07 UTC


README

A 'pretty good' mechanize-like php library for managing cookies and submitting forms.

Read the Documentation

require 'pgbrowser.php';

$b = new 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 'pgbrowser.php';
require 'phpquery.php';
$browser = new PGBrowser('advanced');
$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