2017 © Pedro Peláez
 

library robots-txt-checker

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

image

tomverran/robots-txt-checker

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  • Sunday, March 11, 2018
  • by tomverran
  • Repository
  • 4 Watchers
  • 10 Stars
  • 4,166 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 14 Versions
  • 18 % Grown

The README.md

Robots.txt checker

Build Status Packagist Test Coverage Code Climate, (*1)

Given a robots.txt file this library will give you a straight forward yes/no as to whether you're allowed to access a given resource with a given user agent., (*2)

This library has been built with reference to both Google's robots.txt specification and the draft norobots RFC from 1996(!). As such all the following features are supported:, (*3)

  • Wildcards in paths, including across directory boundaries
  • The '$' suffix to anchor a path match to the end of a URL
  • Sorting of multiple matching user-agent/path blocks by user-agent length
  • Decoding of URL encoded paths, with the exception of forward slashes
  • A trailing slash on a path indicating that all files under that directory should match

If you find any bugs with this library please don't hesitate to let me know, either create an issue on GitHub or submit a pull request., (*4)

Installation

Either type the following into your terminal:, (*5)

composer require tomverran/robots-txt-checker

or add the following to your composer.json:, (*6)

"require": {
    "tomverran/robots-txt-checker": "^1.15"
}

Example Usage

I personally use this library alongside an http client library such that all requests go through a class that checks the site's robots.txt first. Basic usage is as follows:, (*7)

<?php
use \tomverran\Robot\RobotsTxt;
$robotsTxt = new RobotsTxt(file_get_contents('http://your-site-here/robots.txt'));
$canViewPage = $robotsTxt->isAllowed('my-user-agent', '/some/path/');

License

tl;dr MIT license, (*8)

Copyright (c) 2014, 2018 Tom Verran, (*9)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*10)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*11)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*12)

The Versions

11/03 2018

dev-master

9999999-dev https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

10/03 2018

dev-docker-tests

dev-docker-tests https://tvc.io

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

crawler robots.txt

10/03 2018

1.15

1.15.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

05/01 2017

1.14

1.14.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

31/10 2016

1.13

1.13.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

05/06 2016

1.12.1

1.12.1.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

05/06 2016

1.12

1.12.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

06/03 2016

1.11

1.11.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

06/03 2016

1.10

1.10.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

06/03 2016

1.10-beta

1.10.0.0-beta https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

03/12 2015

1.02

1.02.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

10/11 2015

1.02-beta

1.02.0.0-beta https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

09/07 2014

1.01

1.01.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt

15/04 2014

1.0

1.0.0.0 https://carefulcoder.co.uk

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

crawler robots.txt