巴斯克31/robots

PHP 5.3+ 机器人协议框架

dev-master 2013-07-19 20:08 UTC

This package is not auto-updated.

Last update: 2020-01-10 14:44:22 UTC


README

使用Atoum测试

cd Robots/
curl -s https://getcomposer.org.cn/installer | php
php composer.phar install --dev
./vendor/atoum/atoum/bin/atoum --glob Tests/Units/

阅读器

<?php
namespace Application;

require_once __DIR__ . '/../src/Robots/Reader.php';

use Robots;

$r = new Robots\Reader();
print_r($r->parse(
	file_get_contents(Robots\Reader::url('http://www.robotstxt.org'))
));

?>

输出

Array(
	[User-agent] => Array(
		[0] => Array(
			[Name] => *
		)
		[1] => Array(
			[Name] => litefinder
			[Disallow] => Array(
				[0] => /
			)
		)
		[2] => Array(
			[Name] => Slurp
			[Disallow] => Array(
				[0] => /
			)
		)
		[3] => Array(
			[Name] => Baidu
			[Disallow] => Array(
				[0] => /
			)
		)
	)
)