diggin/diggin-robotrules
Composer 安装命令:
composer require diggin/diggin-robotrules
包简介
parser/handler for Robots Exclusion Protocol (robots.txt and more)
README 文档
README
PHP parser/handler for Robots Exclusion Protocol (robots.txt and more..)
Features
-
implements http://www.robotstxt.org/norobots-rfc.txt
- [DONE] "3.2.2 The Allow and Disallow lines" - as test-case
- [DONE] "4.Examples" as test-case
-
passing Nutch's test code ref
- [DONE] @see tests/Diggin/RobotRules/Imported/NutchTest.php
-
parsing & handling html-meta
ToDos
- handle Crawl-Delay
- sync or testing a little pattern w/ Google Test robots.txt tool
- rewrite with PHPPEG.(because current preg* base parser makes difficulty.)
- more test, refactoring on and on..
USAGE
<?php use Diggin\RobotRules\Accepter\TxtAccepter; use Diggin\RobotRules\Parser\TxtStringParser; $robotstxt = <<<'ROBOTS' # sample robots.txt User-agent: YourCrawlerName Disallow: User-agent: * Disallow: /aaa/ #comment ROBOTS; $accepter = new TxtAccepter; $accepter->setRules(TxtStringParser::parse($robotstxt)); $accepter->setUserAgent('foo'); var_dump($accepter->isAllow('/aaa/')); //false var_dump($accepter->isAllow('/b.html')); //true $accepter->setUserAgent('YourCrawlerName'); var_dump($accepter->isAllow('/aaa/')); // true
INSTALL
Diggin_RobotRules is following PSR-0, so to register namespace Diggin\RobotRules into your ClassLoader.
To install via composer
- $php composer.phar require diggin/diggin-robotrules "dev-master"
License
Diggin_RobotRules is licensed under new-bsd.
Reference & alternatives in others language.
- Perl
- Python
- Ruby
统计信息
- 总下载量: 187
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2012-10-03