add server-side code and mobile app code

This commit is contained in:
Odweta
2024-01-07 01:11:37 +00:00
parent 5aff4ac5a6
commit 263efd5b65
402 changed files with 71488 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
composer.lock
phpunit.xml
vendor
+32
View File
@@ -0,0 +1,32 @@
<?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);
}
}
@@ -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();
+25
View File
@@ -0,0 +1,25 @@
<?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);
}
}
+19
View File
@@ -0,0 +1,19 @@
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.
+117
View File
@@ -0,0 +1,117 @@
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
+21
View 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
}
+30
View File
@@ -0,0 +1,30 @@
{
"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"]
}
}
+17
View File
@@ -0,0 +1,17 @@
<?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>