Loading repository data…
Loading repository data…
sonata-project / repository
[deprecated] GoutteBundle, a thin wrapper around Goutte (a simple PHP Web Scraper)
GoutteBundle integrated the Goutte project from Fabien Potencier (https://github.com/fabpot/Goutte) into the Symfony2 project.
deps then run php bin/vendors install::[goutte]
git=git://github.com/fabpot/Goutte.git
version=5ecceb7c28a428fb93f283982cc4f5edfd96630b
[SonataGoutteBundle]
git=http://github.com/sonata-project/SonataGoutteBundle.git
target=/bundles/Sonata/GoutteBundle
app/AppKernel.php::<?php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Sonata\GoutteBundle\SonataGoutteBundle(),
// ...
);
}
app/autoload.php::<?php
$loader->registerNamespaces(array(
// ...
'Goutte' => __DIR__.'/../vendor/goutte/src',
'Sonata' => __DIR__.'/../vendor/bundles',
));
sonata_goutte:
class: Sonata\GoutteBundle\Manager
clients:
default:
config:
adapter: Zend\Http\Client\Adapter\Socket
curl:
config:
maxredirects: 0
timeout: 30
useragent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US) Gecko/20100401 Firefox/3.6.3
adapter: Sonata\GoutteBundle\Adapter\Curl
verbose_log: %kernel.logs_dir%/curl.log
verbose: true
<?php
public function fetchAction()
{
$client = $this->get('goutte')
->getNamedClient('curl');
$crawler = $client->request('GET', 'http://symfony-reloaded.org/');
$response = $client->getResponse();
$content = $response->getContent();
// do stuff with the crawler and related information
}