Pathologic was missing because of a .git folder inside.
[yaffs-website] / vendor / fabpot / goutte / README.rst
1 Goutte, a simple PHP Web Scraper
2 ================================
3
4 Goutte is a screen scraping and web crawling library for PHP.
5
6 Goutte provides a nice API to crawl websites and extract data from the HTML/XML
7 responses.
8
9 Requirements
10 ------------
11
12 Goutte depends on PHP 5.5+ and Guzzle 6+.
13
14 .. tip::
15
16     If you need support for PHP 5.4 or Guzzle 4-5, use Goutte 2.x (latest `phar
17     <https://github.com/FriendsOfPHP/Goutte/releases/download/v2.0.4/goutte-v2.0.4.phar>`_).
18
19     If you need support for PHP 5.3 or Guzzle 3, use Goutte 1.x (latest `phar
20     <https://github.com/FriendsOfPHP/Goutte/releases/download/v1.0.7/goutte-v1.0.7.phar>`_).
21
22 Installation
23 ------------
24
25 Add ``fabpot/goutte`` as a require dependency in your ``composer.json`` file:
26
27 .. code-block:: bash
28
29     composer require fabpot/goutte
30
31 Usage
32 -----
33
34 Create a Goutte Client instance (which extends
35 ``Symfony\Component\BrowserKit\Client``):
36
37 .. code-block:: php
38
39     use Goutte\Client;
40
41     $client = new Client();
42
43 Make requests with the ``request()`` method:
44
45 .. code-block:: php
46
47     // Go to the symfony.com website
48     $crawler = $client->request('GET', 'https://www.symfony.com/blog/');
49
50 The method returns a ``Crawler`` object
51 (``Symfony\Component\DomCrawler\Crawler``).
52
53 To use your own Guzzle settings, you may create and pass a new Guzzle 6
54 instance to Goutte. For example, to add a 60 second request timeout:
55
56 .. code-block:: php
57
58     use Goutte\Client;
59     use GuzzleHttp\Client as GuzzleClient;
60     
61     $goutteClient = new Client();
62     $guzzleClient = new GuzzleClient(array(
63         'timeout' => 60,
64     ));
65     $goutteClient->setClient($guzzleClient);
66
67 Click on links:
68
69 .. code-block:: php
70
71     // Click on the "Security Advisories" link
72     $link = $crawler->selectLink('Security Advisories')->link();
73     $crawler = $client->click($link);
74
75 Extract data:
76
77 .. code-block:: php
78
79     // Get the latest post in this category and display the titles
80     $crawler->filter('h2 > a')->each(function ($node) {
81         print $node->text()."\n";
82     });
83
84 Submit forms:
85
86 .. code-block:: php
87
88     $crawler = $client->request('GET', 'https://github.com/');
89     $crawler = $client->click($crawler->selectLink('Sign in')->link());
90     $form = $crawler->selectButton('Sign in')->form();
91     $crawler = $client->submit($form, array('login' => 'fabpot', 'password' => 'xxxxxx'));
92     $crawler->filter('.flash-error')->each(function ($node) {
93         print $node->text()."\n";
94     });
95
96 More Information
97 ----------------
98
99 Read the documentation of the `BrowserKit`_ and `DomCrawler`_ Symfony
100 Components for more information about what you can do with Goutte.
101
102 Pronunciation
103 -------------
104
105 Goutte is pronounced ``goot`` i.e. it rhymes with ``boot`` and not ``out``.
106
107 Technical Information
108 ---------------------
109
110 Goutte is a thin wrapper around the following fine PHP libraries:
111
112 * Symfony Components: `BrowserKit`_, `CssSelector`_ and `DomCrawler`_;
113
114 *  `Guzzle`_ HTTP Component.
115
116 License
117 -------
118
119 Goutte is licensed under the MIT license.
120
121 .. _`Composer`: https://getcomposer.org
122 .. _`Guzzle`: http://docs.guzzlephp.org
123 .. _`BrowserKit`: https://symfony.com/components/BrowserKit
124 .. _`DomCrawler`: https://symfony.com/doc/current/components/dom_crawler.html
125 .. _`CssSelector`: https://symfony.com/doc/current/components/css_selector.html