rebelinblue/fluent-web-crawler
Composer 安装命令:
composer require rebelinblue/fluent-web-crawler
包简介
A web crawler with a fluent interface
README 文档
README
Fluent Web Crawler
A web scraping library for PHP with a nice fluent interface.
A fork of laravel/browser-kit-testing, repurposed to use with real HTTP requests.
Developed for a project I worked on at Sainsbury's.
Requirements
PHP 7.1+ and Goutte 3.1+
Installation
The recommended way to install the library is through Composer.
Add rebelinblue/fluent-web-crawler as a require dependency in your composer.json file:
composer require rebelinblue/fluent-web-crawler
Usage
Create an instance of the Crawler
use REBELinBLUE\Crawler; $crawler = new Crawler();
Visit a URL
$crawler->visit('http://www.example.com');
Interact with the page
$crawler->type('username', 'admin') ->type('password', 'password') ->press('Login'); // This can also be written as the following $crawler->submitForm('Login', [ 'username' => 'admin', 'password' => 'password', ]);
Check the response is as expected
if ($crawler->dontSeeText('Hello World')) { throw new \Exception('The page does not contain the expected text'); }
For a full list of the available actions see api.md.
Customising the HTTP client settings
If you wish to customize the instance of Goutte which is used (or more likely, the instance of Guzzle), you can inject your own instance when constructing the class. For example, you may want to increase Guzzle's timeout
use Goutte\Client as GoutteClient; use GuzzleHttp\Client as GuzzleClient; $goutteClient = new GoutteClient(); $guzzleClient = new GuzzleClient([ 'timeout' => 60, ]); $goutteClient->setClient($guzzleClient); $crawler = new Crawler($goutteClient);
Further Reading
Fluent Crawler is a wrapper around the following PHP libraries.
- Goutte web scraper.
- Symfony BrowserKit, CssSelector and DomCrawler.
- Guzzle HTTP client.
rebelinblue/fluent-web-crawler 适用场景与选型建议
rebelinblue/fluent-web-crawler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.59k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2017 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 rebelinblue/fluent-web-crawler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rebelinblue/fluent-web-crawler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-24