npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@goateeya/html-scanner

v1.0.4

Published

html file rule checking by config

Downloads

18

Readme

htmlscanner

convert html file to dom object, then using document.querySelectorAll to find element

Change log

2018/06/13 Gordan 使用javascript ES6 class的寫法重寫scanner.js(改使用newscanenr.js)

dependencies

jsdom 11.11.0

安裝方式

從Github
1.git clone https://github.com/goateeya/htmlscanner.git
2.cd htmlscanner/
3.npm install
4.node test/app.js

從npm

 npm i @goateeya/html-scanner  

or

package.json中dependencies加入

"@goateeya/html-scanner": "^1.0.4"  

接著下npm安裝指令

npm install  

介接/使用方式

1.先去lib/config.js 設定input/output file path
使用npm安裝路徑會在node_modules\@goateeya\html-scanner\lib下

2.Github:

var Scanner = require('scanner');

or

npm:

var Scanner = require('@goateeya/html-scanner');
var readerStream = fs.createReadStream('xxxxx.html');
var scanner = Scanner(readerStream);
scanner.run();

or

var scanner = Scanner();
scanner.run();

執行後會產出檔案於./output/xxxxx.html_check_result.txt (預設產出路徑為./output/)

Configure

First open lib/config.js

config.isloadFromFile = true;
是否讀取檔案,但如果run function傳入readerStream,會優先使用傳入的readerStream

config.htmlFilePath = 'F:/git/repo/htmlscanner/input/testcase.4.html';
本機html檔案位置

config.fileEncoding = 'utf8';
檔案encoding編碼

config.outputFileFolder = './output/';
產出結果檔案路徑

config.rules = ['exists','notexists','morethan'];
會執行的rule,實作於scanner.js中的function scanner.ruleValidate()

config.rule.xxxxx.profiles
xxxxx表示rule name,其中profiles下有4個attribute
selector: CSS selector用來抓取dom物件
enable: profile啟用flag
message: 符合條件會拋出的訊息
compareTo: 元素數量比對基準

Rule說明

exists
html存在至少一個元素,則符合條件,並彈出message

notexists
html不存在元素,則符合條件,並彈出message

morethan
html中元素大於compareTo的數字,則符合條件,並彈出message

如何新增Profile(已有規則)

於現有config.RULENAME.exists.profiles中,新增一組profile

EXAMPLE:<meta name=“robots” /> existing or not
於config.rule.exists.profiles加入一組物件

{'selector': 'meta[name="robots"]',  
'enable': true,  
'message' 'There are %i <meta> tag with name = "robots" attribute'}  

如何新增rule(尚未有規則)

1.於config.js中的Array變數config.rules,加入rule name
2.新增該rule的profiles:
config.rule.RULENAME.profiles=[{}...];
3.於scanner.js中的function scanner.ruleValidate()實作該rule