Repository: FriendsOfPHP/Goutte
Branch: master
Commit: 1e6989df37b3
Files: 9
Total size: 7.8 KB
Directory structure:
gitextract_8gu1x5lm/
├── .gitignore
├── Goutte/
│ ├── Client.php
│ ├── Resources/
│ │ └── phar-stub.php
│ └── Tests/
│ └── ClientTest.php
├── LICENSE
├── README.rst
├── box.json
├── composer.json
└── phpunit.xml.dist
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
composer.lock
phpunit.xml
vendor
================================================
FILE: Goutte/Client.php
================================================
<?php
/*
* This file is part of the Goutte package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Goutte;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\History;
use Symfony\Component\BrowserKit\HttpBrowser;
use Symfony\Contracts\HttpClient\HttpClientInterface;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated Use Symfony\Component\BrowserKit\HttpBrowser directly instead
*/
class Client extends HttpBrowser
{
public function __construct(HttpClientInterface $client = null, History $history = null, CookieJar $cookieJar = null)
{
trigger_deprecation('fabpot/goutte', '4.0', 'The "%s" class is deprecated, use "%s" instead.', __CLASS__, HttpBrowser::class);
parent::__construct($client, $history, $cookieJar);
}
}
================================================
FILE: Goutte/Resources/phar-stub.php
================================================
<?php
/*
* This file is part of the Goutte utility.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
require_once 'phar://'.__FILE__.'/vendor/autoload.php';
__HALT_COMPILER();
================================================
FILE: Goutte/Tests/ClientTest.php
================================================
<?php
/*
* This file is part of the Goutte package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Goutte\Tests;
use Goutte\Client;
use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\HttpBrowser;
class ClientTest extends TestCase
{
public function testNew()
{
$client = new Client();
$this->assertInstanceOf(HttpBrowser::class, $client);
}
}
================================================
FILE: LICENSE
================================================
Copyright (c) 2010-present Fabien Potencier
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.
================================================
FILE: README.rst
================================================
Goutte, a simple PHP Web Scraper
================================
Goutte is a screen scraping and web crawling library for PHP.
Goutte provides a nice API to crawl websites and extract data from the HTML/XML
responses.
**WARNING**: This library is deprecated. As of v4, Goutte became a simple proxy
to the `HttpBrowser class
<https://symfony.com/doc/current/components/browser_kit.html#making-external-http-requests>`_
from the `Symfony BrowserKit <https://symfony.com/browser-kit>`_ component. To
migrate, replace ``Goutte\Client`` by
``Symfony\Component\BrowserKit\HttpBrowser`` in your code.
Requirements
------------
Goutte depends on PHP 7.1+.
Installation
------------
Add ``fabpot/goutte`` as a require dependency in your ``composer.json`` file:
.. code-block:: bash
composer require fabpot/goutte
Usage
-----
Create a Goutte Client instance (which extends
``Symfony\Component\BrowserKit\HttpBrowser``):
.. code-block:: php
use Goutte\Client;
$client = new Client();
Make requests with the ``request()`` method:
.. code-block:: php
// Go to the symfony.com website
$crawler = $client->request('GET', 'https://www.symfony.com/blog/');
The method returns a ``Crawler`` object
(``Symfony\Component\DomCrawler\Crawler``).
To use your own HTTP settings, you may create and pass an HttpClient
instance to Goutte. For example, to add a 60 second request timeout:
.. code-block:: php
use Goutte\Client;
use Symfony\Component\HttpClient\HttpClient;
$client = new Client(HttpClient::create(['timeout' => 60]));
Click on links:
.. code-block:: php
// Click on the "Security Advisories" link
$link = $crawler->selectLink('Security Advisories')->link();
$crawler = $client->click($link);
Extract data:
.. code-block:: php
// Get the latest post in this category and display the titles
$crawler->filter('h2 > a')->each(function ($node) {
print $node->text()."\n";
});
Submit forms:
.. code-block:: php
$crawler = $client->request('GET', 'https://github.com/');
$crawler = $client->click($crawler->selectLink('Sign in')->link());
$form = $crawler->selectButton('Sign in')->form();
$crawler = $client->submit($form, ['login' => 'fabpot', 'password' => 'xxxxxx']);
$crawler->filter('.flash-error')->each(function ($node) {
print $node->text()."\n";
});
More Information
----------------
Read the documentation of the `BrowserKit`_, `DomCrawler`_, and `HttpClient`_
Symfony Components for more information about what you can do with Goutte.
Pronunciation
-------------
Goutte is pronounced ``goot`` i.e. it rhymes with ``boot`` and not ``out``.
Technical Information
---------------------
Goutte is a thin wrapper around the following Symfony Components:
`BrowserKit`_, `CssSelector`_, `DomCrawler`_, and `HttpClient`_.
License
-------
Goutte is licensed under the MIT license.
.. _`Composer`: https://getcomposer.org
.. _`BrowserKit`: https://symfony.com/components/BrowserKit
.. _`DomCrawler`: https://symfony.com/doc/current/components/dom_crawler.html
.. _`CssSelector`: https://symfony.com/doc/current/components/css_selector.html
.. _`HttpClient`: https://symfony.com/doc/current/components/http_client.html
================================================
FILE: box.json
================================================
{
"output": "goutte.phar",
"chmod": "0755",
"compactors": [
"Herrera\\Box\\Compactor\\Php"
],
"extract": false,
"files": [
"LICENSE",
"Goutte/Client.php"
],
"finder": [
{
"name": ["*.php", "*.pem*"],
"exclude": ["Tests", "tests"],
"in": "vendor"
}
],
"stub": "Goutte/Resources/phar-stub.php",
"web": false
}
================================================
FILE: composer.json
================================================
{
"name": "fabpot/goutte",
"type": "application",
"description": "A simple PHP Web Scraper",
"keywords": ["scraper"],
"homepage": "https://github.com/FriendsOfPHP/Goutte",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"require": {
"php": ">=7.1.3",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/browser-kit": "^4.4|^5.0|^6.0",
"symfony/css-selector": "^4.4|^5.0|^6.0",
"symfony/dom-crawler": "^4.4|^5.0|^6.0",
"symfony/http-client": "^4.4|^5.0|^6.0",
"symfony/mime": "^4.4|^5.0|^6.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^6.0"
},
"autoload": {
"psr-4": { "Goutte\\": "Goutte" },
"exclude-from-classmap": ["Goutte/Tests"]
}
}
================================================
FILE: phpunit.xml.dist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="Goutte Test Suite">
<directory>./Goutte/Tests</directory>
</testsuite>
</testsuites>
</phpunit>
gitextract_8gu1x5lm/ ├── .gitignore ├── Goutte/ │ ├── Client.php │ ├── Resources/ │ │ └── phar-stub.php │ └── Tests/ │ └── ClientTest.php ├── LICENSE ├── README.rst ├── box.json ├── composer.json └── phpunit.xml.dist
SYMBOL INDEX (4 symbols across 2 files)
FILE: Goutte/Client.php
class Client (line 24) | class Client extends HttpBrowser
method __construct (line 26) | public function __construct(HttpClientInterface $client = null, Histor...
FILE: Goutte/Tests/ClientTest.php
class ClientTest (line 18) | class ClientTest extends TestCase
method testNew (line 20) | public function testNew()
Condensed preview — 9 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (9K chars).
[
{
"path": ".gitignore",
"chars": 33,
"preview": "composer.lock\nphpunit.xml\nvendor\n"
},
{
"path": "Goutte/Client.php",
"chars": 947,
"preview": "<?php\n\n/*\n * This file is part of the Goutte package.\n *\n * (c) Fabien Potencier <fabien@symfony.com>\n *\n * For the full"
},
{
"path": "Goutte/Resources/phar-stub.php",
"chars": 298,
"preview": "<?php\n\n/*\n * This file is part of the Goutte utility.\n *\n * (c) Fabien Potencier <fabien@symfony.com>\n *\n * This source "
},
{
"path": "Goutte/Tests/ClientTest.php",
"chars": 534,
"preview": "<?php\n\n/*\n * This file is part of the Goutte package.\n *\n * (c) Fabien Potencier <fabien@symfony.com>\n *\n * For the full"
},
{
"path": "LICENSE",
"chars": 1068,
"preview": "Copyright (c) 2010-present Fabien Potencier\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
},
{
"path": "README.rst",
"chars": 3239,
"preview": "Goutte, a simple PHP Web Scraper\n================================\n\nGoutte is a screen scraping and web crawling library "
},
{
"path": "box.json",
"chars": 428,
"preview": "{\n \"output\": \"goutte.phar\",\n \"chmod\": \"0755\",\n \"compactors\": [\n \"Herrera\\\\Box\\\\Compactor\\\\Php\"\n ],\n "
},
{
"path": "composer.json",
"chars": 868,
"preview": "{\n \"name\": \"fabpot/goutte\",\n \"type\": \"application\",\n \"description\": \"A simple PHP Web Scraper\",\n \"keywords\":"
},
{
"path": "phpunit.xml.dist",
"chars": 534,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<phpunit backupGlobals=\"false\"\n backupStaticAttributes=\"false\"\n "
}
]
About this extraction
This page contains the full source code of the FriendsOfPHP/Goutte GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 9 files (7.8 KB), approximately 2.3k tokens, and a symbol index with 4 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.