This commit is contained in:
Simon Vieille 2020-04-14 16:32:56 +02:00
parent 9b41d509b3
commit 8826cd2ba8
Signed by: deblan
GPG key ID: 03383D15A1D31745
4 changed files with 30 additions and 13 deletions

View file

@ -1,4 +1,9 @@
{
"name": "deblan-scraper",
"description": "Web scraper using CSS selector",
"version": "1.0.0",
"main": "src/index.js",
"devDependencies": {},
"dependencies": {
"cheerio": "^1.0.0-rc.3",
"extends-classes": "^1.0.5",
@ -6,5 +11,17 @@
"request-promise": "^4.2.5",
"striptags": "^3.1.1",
"trim": "^0.0.1"
}
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitnet.fr/deblan/scraper.git"
},
"keywords": [
"scraper"
],
"author": "Simon Vieille <contact@deblan.fr> (https://www.deblan.io)",
"license": "ISC"
}

View file

@ -9,9 +9,9 @@ class Input {
* @param object process
*/
constructor(process) {
this.args = Minimist(process.argv.slice(2));
this.node = process.argv[0];
this.script = process.argv[1];
this.args = Minimist(process.argv.slice(2))
this.node = process.argv[0]
this.script = process.argv[1]
}
/**
@ -24,11 +24,11 @@ class Input {
*/
get(name, defaultValue) {
if (this.has(name)) {
return this.args[name];
return this.args[name]
}
if (defaultValue !== undefined) {
return defaultValue;
return defaultValue
}
return null;
@ -42,7 +42,7 @@ class Input {
* @return boolean
*/
has(name) {
return this.args.hasOwnProperty(name);
return this.args.hasOwnProperty(name)
}
/**
@ -51,7 +51,7 @@ class Input {
* @return boolean
*/
empty() {
return Object.keys(this.args).length === 1;
return Object.keys(this.args).length === 1
}
}

View file

@ -11,15 +11,15 @@ class Output {
data,
function(key, value) {
if (value === undefined) {
return null;
return null
}
return value;
return value
},
pretty ? 2 : null
);
return this.write(data);
return this.write(data)
}
/**

View file

@ -35,9 +35,9 @@ Optional parameters
HTTP
--method [METHOD] HTTP Method
--accept-http-error Accepts all status code (like 404)
--accept-http-error Accepts all status codes (like 404)
--verbose, -v Show message of error
--verbose, -v Show message of error
`
if (input.has('help')) {