同步操作将从 Gitee 极速下载/goutte 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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.
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).
If you need support for PHP 5.3 or Guzzle 3, use Goutte 1.x (latest phar).
Add fabpot/goutte
as a require dependency in your composer.json
file:
composer require fabpot/goutte
Create a Goutte Client instance (which extends
Symfony\Component\BrowserKit\Client
):
use Goutte\Client;
$client = new Client();
Make requests with the request()
method:
// 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 Guzzle settings, you may create and pass a new Guzzle 6 instance to Goutte. For example, to add a 60 second request timeout:
use Goutte\Client;
use GuzzleHttp\Client as GuzzleClient;
$goutteClient = new Client();
$guzzleClient = new GuzzleClient(array(
'timeout' => 60,
));
$goutteClient->setClient($guzzleClient);
Click on links:
// Click on the "Security Advisories" link
$link = $crawler->selectLink('Security Advisories')->link();
$crawler = $client->click($link);
Extract data:
// Get the latest post in this category and display the titles
$crawler->filter('h2 > a')->each(function ($node) {
print $node->text()."\n";
});
Submit forms:
$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, array('login' => 'fabpot', 'password' => 'xxxxxx'));
$crawler->filter('.flash-error')->each(function ($node) {
print $node->text()."\n";
});
Read the documentation of the BrowserKit and DomCrawler Symfony Components for more information about what you can do with Goutte.
Goutte is pronounced goot
i.e. it rhymes with boot
and not out
.
Goutte is a thin wrapper around the following fine PHP libraries:
Goutte is licensed under the MIT license.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。