Skip to content

Instantly share code, notes, and snippets.

@franmomu
Created February 3, 2014 14:28
Show Gist options
  • Save franmomu/8784784 to your computer and use it in GitHub Desktop.
Save franmomu/8784784 to your computer and use it in GitHub Desktop.
Goutte Playground
<?php
require_once __DIR__.'/vendor/autoload.php';
use Goutte\Client;
$client = new Client();
// Login page
$crawler = $client->request('GET', 'http://x3demob.cpx3demo.com:2082/?locale=en');
// Select Login form
$form = $crawler->selectButton('Log in')->form();
// Submit form
$crawler = $client->submit($form, array(
'user' => 'x3demob',
'pass' => 'x3demob',
));
// PHP Configuration page
$link = $crawler->selectLink('PHP Configuration')->link();
$crawler = $client->click($link);
// Find PHP Configuration rows
$configurationRows = $crawler->filter('#phptbl tbody tr');
$configurationRows->each(function($configurationRow, $index) {
$directive = $configurationRow->filter('td')->eq(1)->text();
$value = $configurationRow->filter('td')->eq(3)->text();
echo sprintf("%-20s = %s\n", $directive, $value);
});
{
"require": {
"fabpot/goutte": "1.0.*@dev"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment