tea-detector v1.0.4
Simple SEO detector cli tool
Installation
NOTE! Add "--global" flag to ensure cli working well
$ npm install tea-detector --global
Usage
1. Get Help
$ tea-detect -h
Options:
-V, --version output the version number
-f, --file [name|path] The input file path(ex: demo.html)
-u, --url [addr] The url source (ex: http://www.demo.com)
-o, --output [name] The output file name (ex: result.txt)
-c, --conf Using custom rules: myrules.json
-r, --rules [rule_no,...] The number of rule that applied to detector, seperate by ","
-h, --help output usage information
2. Detect File/URL By Using Default Rules
// Read from file(s)
$ tea-detect -f file1[,file2...]
// Read from url(s)
$ tea-detect -u url1[,url2...]
3. Detect By Using Specific Rules
// Only use rule no. 1,3 and 5
$ tea-detect -f file.html -r 1,3,5
4. Default Rules
Please check lib/seorule_conf_default.json
in this repository.
5 Default Rules Below:
1. Detect if any \ tag without alt attribute
2. Detect if any \ tag without rel attribute
3. In \ tag
+ Detect if header doesn’t have \ tag
+ Detect if header doesn’t have \<meta name=“descriptions” ... /> tag
+ Detect if header doesn’t have \<meta name=“keywords” ... /> tag
4. Detect if there’re more than 15 \ tag in HTML
5. Detect if a HTML have more than one \ tag
5. Custom Your Rule
Please create a JSON file named myrules.json
in your project root.
Format:
- Json array
- Each element defines a SEO detect rule.
- Keys in rule level (all required):
- "no": \ Rule number
- "region": \ The document area to be detected
- "conditions": \ The rule's conditions
- Keys in condition level:
- "tag": \ Tag name (required)
- "attr": \ Tag attribute
- "val": \ The attribute's value (only enabled while "attr" key is exist)
- "length": \ The max. tag number (detected if there are more tags than this)
Example:
[
{
"no": "1",
"region": "body",
"conditions": [
{
"tag": "img",
"attr": "alt"
}
]
},
...
]
6. Test Your Custom Rules Before Detect
Remind: Please make sure mocha.js has been installed in your env
- copy
test/rule.spec.js
to your project - Modify your
package.json
as:
...
"scripts": {
"test": "mocha test/rule.spec.js"
},
...
- Run
npm test
in console - If everything looks ok, then run
tea-detect -f file.html -c
7. Save Detection Result
You can save all the results into file
$ tea-detect -f file.html -o log.txt
(note) It will also create an error log automatically.