detection-worm-js
v1.3.2
Published
主要针对使用XPath语法对网站解析,以及常用工具集
Maintainers
Readme
detection-worm-js
请求页面,并使用XPATH语法进行页面解析 (github)
安装
npm install -S detection-worm-js
引用
NodeJS
const dwj = require('detection-worm-js');
const Runner = dwj.WebLoader.Runner;
const xpath = dwj.XPath;
Runner("xxxxxx").then(res => {
const xp = new xpath(res, true);
const param = [ ];
console.log(xp.selector(`xpath解析字符串`, param))
})ES6
import { XPath, WebLoader, ObjectType } from 'detection-worm-js';
WebLoader.Runner("xxxxxx").then(res => {
const xp = new XPath(res, true);
const param = [ ];
console.log(xp.selector(`xpath解析字符串`, param))
})方法使用
使用ThreadPool可以结合ThreadWorker类使用:
main.js:
const { ThreadPool } = require('detection-worm-js');
const workerPool = new ThreadPool().setWorkerOption(
{ filename: './ChildWorker.js' }
).start(5);
for (let i = 1; i <= 100; i++) {
workerPool.run(i, (err, result) => {
// 回调函数
})
}ChildWorker.js:
const { AbstractWorker } = require('detection-worm-js');
class Test extends AbstractWorker {
// 重写`task`方法
// @param param是入参
task(param) {
}
}
new Test();