{{tag>php crawler web httpclient}}

====== Goutte (crawler) ======

PHP эмулятор браузера

  * https://github.com/FriendsOfPHP/Goutte :!:
===== Get =====

<code php>
use Goutte\Client;

$client = new Client();

$crawler = $client->request('GET', 'http://www.symfony.com/blog/');
$link = $crawler->selectLink('Security Advisories')->link();
$crawler = $client->click($link);

$crawler->filter('h2.post > a')->each(function ($node) {
    print $node->text()."\n";
});
</code>

===== Submit =====

<code php>
use Goutte\Client;

$client = new Client();

$crawler = $client->request('GET', 'http://github.com/');
$crawler = $client->click($crawler->selectLink('Sign in')->link());
$form = $crawler->selectButton('Sign in')->form();
$crawler = $client->submit($form, array('login' => 'fabpot', 'password' => 'xxxxxx'));
$crawler->filter('.flash-error')->each(function ($node) {
    print $node->text()."\n";
});
</code>

====== Стытьи ======

  * http://zrashwani.com/simple-web-spider-php-goutte