Socket
Socket
Sign inDemoInstall

seo-cop

Package Overview
Dependencies
72
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    seo-cop

Node.js package to parse HTML and show SEO defects


Version published
Weekly downloads
2
Maintainers
1
Created
Weekly downloads
 

Readme

Source

SEO Cop

Node.js package to parse HTML and show SEO defects

Installation

Install SEO Cop globally using npm:

npm install -g seo-cop

To install the latest version on npm locally and save it in your package's package.json file:

npm install --save-dev seo-cop
Usage & Examples
var Parser = require('seo-cop');

//simple HTML file parsing and printing defects on console
var parser = new Parser({}, "console");
parser.parseFile("home.html");


//input stream and parse data by reading stream. Print defects on console
var fs = require('fs');
var parser = new Parser({}, "console");
var s = fs.createReadStream("home.html");
parser.parseStream(s);


//simple HTML file parsing and write defacts in output file
var parser = new Parser({}, "file");
parser.parseFile("home.html");


//simple HTML file parsing and get result on write stream
var parser = new Parser({}, "stream");
var wStream = parser.outputWriteStream;
wStream.write = function(data, _, done) {
    console.log(data);
    done();
}
parser.parseFile("home.html");


//Disable, Override, Define new rules and match conditions
var parser = new Parser({
    "h1": {
        "isEnabled": false //disable default h1 rule
    },
    "strong": {
        "isEnabled": true,
        "query": "strong",
        "conditions": [
            {
                "self": {
                    "condition": "length.to.be.below",
                    "args": 5 //Override default rule condition
                },
                "error": "There are more than 5 <strong> tag in HTML"
            }
        ]
    },
    "custom": { //define custom rule
        "isEnabled": true,
        "query": "head",
        "conditions": [
            {
                "children": {
                    "condition": "to.containSubset",
                    "args": [{
                        "name": "meta",
                        "attribs": {
                            "name": "robots"
                        }
                    }]
                },
                "error": "<head> without <meta name='robots' ... /> tag"
            }
        ]
    }
}, "console");
parser.parseFile("home.html");


Development

Copy git repository and run:

npm install

This should setup development environment.

Once satisfied with code changes, update tests and run:

npm test

To update the documentation, edit jsDoc comments and run:

npm run-script doc
License

MIT

Keywords

FAQs

Last updated on 21 Feb 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc