Nine Parsecs from Milwaukee
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

robots-txt-parse

1.0.1 • Public • Published

robots-txt-parse Build Status

Streaming robots.txt parser

usage

var parse = require('robots-txt-parse'),
    fs    = require('fs');
 
parse(fs.createReadStream(__dirname + '/robots.txt'))
  .then(function (robots) {
    console.log(robots)
  });
 

assuming this file

user-agent: *
user-agent: googlebot
disallow: /

user-agent: twitterbot
disallow: /
allow: /twitter

user-agent: mozilla
disallow: /path
noindex: /path

Sitemap: http://www.example.com/sitemap.xml

produces following output

{
  "groups": [{
    "agents": [ "*", "googlebot" ],
    "rules": [
      { "rule": "disallow", "path": "/" }
    ]
  }, {
    "agents": [ "twitterbot" ],
    "rules": [
      { "rule": "disallow", "path": "/" },
      { "rule": "allow", "path": "/twitter" }
    ]
  }, {
    "agents": [ "mozilla" ],
    "rules": [
      { "rule": "disallow", "path": "/path" },
      { "rule": "noindex", "path": "/path" }
    ]
  }],
  "extensions": [
    { "extension": "sitemap", "value": "http://www.example.com/sitemap.xml" }
  ]
}

Keywords

none

Install

npm i robots-txt-parse

DownloadsWeekly Downloads

10,447

Version

1.0.1

License

MIT

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar