Developed with love by KnpLabs Hire us for your project!
39

SonataGoutteBundle

by sonata-project

[deprecated] GoutteBundle, a thin wrapper around Goutte (a simple PHP Web Scraper)

What is GoutteBundle ?

GoutteBundle integrated the Goutte project from Fabien Potencier (https://github.com/fabpot/Goutte) into the Symfony2 project.

Installation

  • Add the following entry to 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
  • Register the bundle in app/AppKernel.php::
<?php

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Sonata\GoutteBundle\SonataGoutteBundle(),
        // ...
    );
}
  • Register namespaces in app/autoload.php::
<?php
$loader->registerNamespaces(array(
    // ...
    'Goutte'           => __DIR__.'/../vendor/goutte/src',
    'Sonata'           => __DIR__.'/../vendor/bundles',
));

Configuration

  • edit app/autoload.php and AppKernel.php to add the appropriate lines for the Sonata namespace.
  • edit your config.yml and add these lines
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

Usage

<?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
}

Requirements

  • Symfony2
  • PHP 5.3.2
  • Zend
  • Goutte
Copyright (c) 2010-2013 Thomas Rabaix

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Merge pull request #11 from peterkokot/patch-1
    By rande, 3 years ago
  • Update LICENSE
    By peterkokot, 3 years ago
  • Merge pull request #10 from andreadelfino/master
    By rande, 5 years ago
  • GeckoVersion (rv part) cause wrong 400 response on some IISĀ® server
    By andreadelfino, 5 years ago
  • Merge pull request #9 from greg0ire/master
    By rande, 5 years ago
  • Provide a quick workaround for a huge issue : goutte has completely changed.
    By greg0ire, 5 years ago
  • Merge pull request #7 from greg0ire/patch-2
    By rande, 5 years ago
  • Why not show how to get the bundle's sources too?
    By greg0ire, 5 years ago
  • Merge pull request #6 from greg0ire/patch-1
    By rande, 5 years ago
  • Do not indent at all if using fenced blocks
    By greg0ire, 5 years ago
  • Color the last block
    By greg0ire, 5 years ago
  • Reindent properly
    By greg0ire, 5 years ago
  • Try again with exactly 4 spaces
    By greg0ire, 5 years ago
  • Also use coloration on existing code blocks
    By greg0ire, 5 years ago
  • Try to get even better coloration
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Some code blocks do not look properly for the moment. In markdown code blocks works with spaces, not with tabs. I'm trying the other methods, which use a triple ` + the name of the language. It is supposed to offer syntax highlighting. Read about it here
    By greg0ire, 5 years ago
  • Merge pull request #5 from jofri/library-refactoring
    By rande, 5 years ago
  • Merge pull request #4 from mdpatrick/readme_update_autoload_appkernel
    By rande, 5 years ago
  • Changed so the Client class from the Goutte library is used instead of a copy/pasted file in the bundle. Also added installation instructions to the Readme.
    By morticue, 5 years ago
  • Updated readme to at least mention AppKernel and autoload.
    By mdpatrick, 5 years ago