Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
3
web/vendor/fabpot/goutte/.gitignore
vendored
Normal file
3
web/vendor/fabpot/goutte/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
composer.lock
|
||||
phpunit.xml
|
||||
vendor
|
18
web/vendor/fabpot/goutte/.travis.yml
vendored
Normal file
18
web/vendor/fabpot/goutte/.travis.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 7.0
|
||||
- 5.6
|
||||
- 5.5
|
||||
- hhvm
|
||||
|
||||
install:
|
||||
- travis_retry composer install --no-interaction --prefer-source
|
||||
|
||||
script:
|
||||
- phpunit
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: 7.0
|
208
web/vendor/fabpot/goutte/Goutte/Client.php
vendored
Normal file
208
web/vendor/fabpot/goutte/Goutte/Client.php
vendored
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?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 GuzzleHttp\Client as GuzzleClient;
|
||||
use GuzzleHttp\ClientInterface as GuzzleClientInterface;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Symfony\Component\BrowserKit\Client as BaseClient;
|
||||
use Symfony\Component\BrowserKit\Request;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
|
||||
/**
|
||||
* Client.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @author Michael Dowling <michael@guzzlephp.org>
|
||||
* @author Charles Sarrazin <charles@sarraz.in>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
protected $client;
|
||||
|
||||
private $headers = array();
|
||||
private $auth = null;
|
||||
|
||||
public function setClient(GuzzleClientInterface $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getClient()
|
||||
{
|
||||
if (!$this->client) {
|
||||
$this->client = new GuzzleClient(array('defaults' => array('allow_redirects' => false, 'cookies' => true)));
|
||||
}
|
||||
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
public function setHeader($name, $value)
|
||||
{
|
||||
$this->headers[$name] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeHeader($name)
|
||||
{
|
||||
unset($this->headers[$name]);
|
||||
}
|
||||
|
||||
public function setAuth($user, $password = '', $type = 'basic')
|
||||
{
|
||||
$this->auth = array($user, $password, $type);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function resetAuth()
|
||||
{
|
||||
$this->auth = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function doRequest($request)
|
||||
{
|
||||
$headers = array();
|
||||
foreach ($request->getServer() as $key => $val) {
|
||||
$key = strtolower(str_replace('_', '-', $key));
|
||||
$contentHeaders = array('content-length' => true, 'content-md5' => true, 'content-type' => true);
|
||||
if (0 === strpos($key, 'http-')) {
|
||||
$headers[substr($key, 5)] = $val;
|
||||
}
|
||||
// CONTENT_* are not prefixed with HTTP_
|
||||
elseif (isset($contentHeaders[$key])) {
|
||||
$headers[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$cookies = CookieJar::fromArray(
|
||||
$this->getCookieJar()->allRawValues($request->getUri()),
|
||||
parse_url($request->getUri(), PHP_URL_HOST)
|
||||
);
|
||||
|
||||
$requestOptions = array(
|
||||
'cookies' => $cookies,
|
||||
'allow_redirects' => false,
|
||||
'auth' => $this->auth,
|
||||
);
|
||||
|
||||
if (!in_array($request->getMethod(), array('GET', 'HEAD'))) {
|
||||
if (null !== $content = $request->getContent()) {
|
||||
$requestOptions['body'] = $content;
|
||||
} else {
|
||||
if ($files = $request->getFiles()) {
|
||||
$requestOptions['multipart'] = [];
|
||||
|
||||
$this->addPostFields($request->getParameters(), $requestOptions['multipart']);
|
||||
$this->addPostFiles($files, $requestOptions['multipart']);
|
||||
} else {
|
||||
$requestOptions['form_params'] = $request->getParameters();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($headers)) {
|
||||
$requestOptions['headers'] = $headers;
|
||||
}
|
||||
|
||||
$method = $request->getMethod();
|
||||
$uri = $request->getUri();
|
||||
|
||||
foreach ($this->headers as $name => $value) {
|
||||
$requestOptions['headers'][$name] = $value;
|
||||
}
|
||||
|
||||
// Let BrowserKit handle redirects
|
||||
try {
|
||||
$response = $this->getClient()->request($method, $uri, $requestOptions);
|
||||
} catch (RequestException $e) {
|
||||
$response = $e->getResponse();
|
||||
if (null === $response) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->createResponse($response);
|
||||
}
|
||||
|
||||
protected function addPostFiles(array $files, array &$multipart, $arrayName = '')
|
||||
{
|
||||
if (empty($files)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($files as $name => $info) {
|
||||
if (!empty($arrayName)) {
|
||||
$name = $arrayName.'['.$name.']';
|
||||
}
|
||||
|
||||
$file = [
|
||||
'name' => $name,
|
||||
];
|
||||
|
||||
if (is_array($info)) {
|
||||
if (isset($info['tmp_name'])) {
|
||||
if ('' !== $info['tmp_name']) {
|
||||
$file['contents'] = fopen($info['tmp_name'], 'r');
|
||||
if (isset($info['name'])) {
|
||||
$file['filename'] = $info['name'];
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$this->addPostFiles($info, $multipart, $name);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$file['contents'] = fopen($info, 'r');
|
||||
}
|
||||
|
||||
$multipart[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
public function addPostFields(array $formParams, array &$multipart, $arrayName = '')
|
||||
{
|
||||
foreach ($formParams as $name => $value) {
|
||||
if (!empty($arrayName)) {
|
||||
$name = $arrayName.'['.$name.']';
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$this->addPostFields($value, $multipart, $name);
|
||||
} else {
|
||||
$multipart[] = [
|
||||
'name' => $name,
|
||||
'contents' => $value,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function createResponse(ResponseInterface $response)
|
||||
{
|
||||
return new Response((string) $response->getBody(), $response->getStatusCode(), $response->getHeaders());
|
||||
}
|
||||
}
|
14
web/vendor/fabpot/goutte/Goutte/Resources/phar-stub.php
vendored
Normal file
14
web/vendor/fabpot/goutte/Goutte/Resources/phar-stub.php
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?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();
|
19
web/vendor/fabpot/goutte/LICENSE
vendored
Normal file
19
web/vendor/fabpot/goutte/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2010-2013 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.
|
115
web/vendor/fabpot/goutte/README.rst
vendored
Normal file
115
web/vendor/fabpot/goutte/README.rst
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
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.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Goutte depends on PHP 5.5+ and Guzzle 6+.
|
||||
|
||||
.. tip::
|
||||
|
||||
If you need support for PHP 5.4 or Guzzle 4-5, use Goutte 2.x (latest `phar
|
||||
<https://github.com/FriendsOfPHP/Goutte/releases/download/v2.0.4/goutte-v2.0.4.phar>`_).
|
||||
|
||||
If you need support for PHP 5.3 or Guzzle 3, use Goutte 1.x (latest `phar
|
||||
<https://github.com/FriendsOfPHP/Goutte/releases/download/v1.0.7/goutte-v1.0.7.phar>`_).
|
||||
|
||||
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\Client``):
|
||||
|
||||
.. 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', 'http://www.symfony.com/blog/');
|
||||
|
||||
The method returns a ``Crawler`` object
|
||||
(``Symfony\Component\DomCrawler\Crawler``).
|
||||
|
||||
Fine-tune cURL options:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_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', 'http://github.com/');
|
||||
$crawler = $client->click($crawler->selectLink('Sign in')->link());
|
||||
$form = $crawler->selectButton('Sign in')->form();
|
||||
$crawler = $client->submit($form, array('login' => 'fabpot', 'password' => 'xxxxxx'));
|
||||
$crawler->filter('.flash-error')->each(function ($node) {
|
||||
print $node->text()."\n";
|
||||
});
|
||||
|
||||
More Information
|
||||
----------------
|
||||
|
||||
Read the documentation of the BrowserKit and `DomCrawler
|
||||
<http://symfony.com/doc/any/components/dom_crawler.html>`_ 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 fine PHP libraries:
|
||||
|
||||
* Symfony Components: BrowserKit, CssSelector and DomCrawler;
|
||||
|
||||
* `Guzzle`_ HTTP Component.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Goutte is licensed under the MIT license.
|
||||
|
||||
.. _`Composer`: http://getcomposer.org
|
||||
.. _`Guzzle`: http://docs.guzzlephp.org
|
21
web/vendor/fabpot/goutte/box.json
vendored
Normal file
21
web/vendor/fabpot/goutte/box.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"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
|
||||
}
|
29
web/vendor/fabpot/goutte/composer.json
vendored
Normal file
29
web/vendor/fabpot/goutte/composer.json
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"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": ">=5.5.0",
|
||||
"symfony/browser-kit": "~2.1|~3.0",
|
||||
"symfony/css-selector": "~2.1|~3.0",
|
||||
"symfony/dom-crawler": "~2.1|~3.0",
|
||||
"guzzlehttp/guzzle": "^6.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Goutte\\": "Goutte" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
}
|
||||
}
|
18
web/vendor/fabpot/goutte/phpunit.xml.dist
vendored
Normal file
18
web/vendor/fabpot/goutte/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="./vendor/autoload.php">
|
||||
<testsuites>
|
||||
<testsuite name="Goutte Test Suite">
|
||||
<directory>./Goutte/Tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
Reference in a new issue