deloz/botium
Composer 安装命令:
composer require deloz/botium
包简介
A light web crawl written in PHP
README 文档
README
A light web crawl written in PHP.
Installation
-
Install composer:
curl -sS https://getcomposer.org/installer | phpYou can add Botium as a dependency using the composer.phar CLI:
php composer.phar require deloz/botium:~0.1
-
Alternatively, you can specify Botium as dependency in your project's existing composer.json file:
{ "require": { "deloz/botium": "~0.1" } } -
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
Running the tests
cd tests
php runtest.php
Usage
$settings must contain baseUrl, eg:
$settings = [ 'baseUrl' => 'www.douban.com', 'debug' => true, 'interval' => 10, 'every' => 5, ];
every site is a Class which inherit from Deloz\Botium\Botium with overriding the methods as blow:
namespace Tests; use Symfony\Component\DomCrawler\Crawler; use Deloz\Botium\Response; use Deloz\Botium\Botium; class Haixiu extends Botium { public function start() { $res = $this->crawl('http://www.douban.com/group/haixiuzu/discussion'); $res and $this->index($res); } public function index(Response $res) { $res->doc('td.title > a')->each(function (Crawler $node, $i) { $link = $node->attr('href'); if ($link) { $res = $this->crawl($link); $res and $this->detail($res); } }); } public function detail(Response $res) { $title = $res->doc('#content > h1')->text(); $author = $res->doc('#content > div > div.article > div.topic-content.clearfix > div.topic-doc > h3 > span.from > a')->text(); $images = []; $res->doc('div.topic-content > div.topic-figure.cc img')->each(function (Crawler $node, $i) use (&$images, $res) { $img = $node->attr('src'); if ($img) { $images[] = $img; } }); $this->result([ 'title' => $title, 'author' => $author, 'images' => $images, ]); } public function result(array $item = []) { var_dump($item); } }
more examples, see directory tests
License
licensed using the MIT license
deloz/botium 适用场景与选型建议
deloz/botium 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「search」 「uri」 「spider」 「crawl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 deloz/botium 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 deloz/botium 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 deloz/botium 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
A Laravel package to retrieve data from Google Search Console
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Safely namespaced guzzle psr7 for WP2Static
uri signer with expiration option
Abstraction Layer to index and search entities
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-09