SonataGoutteBundle
[deprecated] GoutteBundle, a thin wrapper around Goutte (a simple PHP Web Scraper)
Install / Use
/learn @sonata-project/SonataGoutteBundleREADME
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
depsthen runphp 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
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
