seo-cop
v1.0.1
Published
Node.js package to parse HTML and show SEO defects
Downloads
11
Maintainers
Readme
SEO Cop
Node.js package to parse HTML and show SEO defects
Installation
Install SEO Cop globally using npm:
npm install -g seo-copTo install the latest version on npm locally and save it in your package's package.json file:
npm install --save-dev seo-copUsage & 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 installThis should setup development environment.
Once satisfied with code changes, update tests and run:
npm testTo update the documentation, edit jsDoc comments and run:
npm run-script docLicense
MIT
