Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
a7d23b9027 | |||
013fa584fa | |||
77a2b1bca7 | |||
edeb7024d0 | |||
01a2b9bc0c | |||
cf9dd3218e | |||
5130a96edc |
18
.woodpecker.yml
Normal file
18
.woodpecker.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
steps:
|
||||||
|
dependencies:
|
||||||
|
image: node:16
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- npm i
|
||||||
|
|
||||||
|
osv-detector:
|
||||||
|
image: gitnet.fr/deblan/osv-detector:v0.10
|
||||||
|
commands:
|
||||||
|
- osv-detector package-lock.json
|
||||||
|
failure: ignore
|
||||||
|
|
||||||
|
tests:
|
||||||
|
image: node:16
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- npm run test
|
13
Jenkinsfile
vendored
13
Jenkinsfile
vendored
|
@ -1,13 +0,0 @@
|
||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
stages {
|
|
||||||
stage('mocha') {
|
|
||||||
steps {
|
|
||||||
sh 'npm install --dev'
|
|
||||||
sh 'npm run test'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Scraper
|
Scraper
|
||||||
=======
|
=======
|
||||||
|
|
||||||
[![Build Status](https://ci.gitnet.fr/buildStatus/icon?job=Gitnet%2Fscraper%2Fmaster)](https://ci.gitnet.fr/job/Gitnet/job/scraper/job/master/)
|
[![Build Status](https://ci.gitnet.fr/api/badges/deblan/scraper/status.svg)](https://ci.gitnet.fr/deblan/scraper)
|
||||||
|
|
||||||
This project is a basic tool to scrap a data from a website
|
This project is a basic tool to scrap a data from a website
|
||||||
using a CSS selector.
|
using a CSS selector.
|
||||||
|
|
2921
package-lock.json
generated
Normal file
2921
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,16 +4,16 @@
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "^8.1.3"
|
"mocha": "^10.2.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^1.0.0-rc.3",
|
"cheerio": "^1.0.0-rc.3",
|
||||||
"extends-classes": "^1.0.5",
|
"extends-classes": "^1.0.5",
|
||||||
"minimist": "^1.2.5",
|
"minimist": "^1.2.5",
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"request-promise": "^4.2.5",
|
"request-promise": "^4.2.6",
|
||||||
"striptags": "^3.1.1",
|
"striptags": "^3.1.1",
|
||||||
"trim": "^0.0.1"
|
"trim": "^1.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha"
|
"test": "mocha"
|
||||||
|
|
|
@ -3,56 +3,56 @@
|
||||||
var Minimist = require('minimist');
|
var Minimist = require('minimist');
|
||||||
|
|
||||||
class Input {
|
class Input {
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param object process
|
* @param object process
|
||||||
*/
|
*/
|
||||||
constructor(process) {
|
constructor(process) {
|
||||||
this.args = Minimist(process.argv.slice(2))
|
this.args = Minimist(process.argv.slice(2))
|
||||||
this.node = process.argv[0]
|
this.node = process.argv[0]
|
||||||
this.script = process.argv[1]
|
this.script = process.argv[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the value of the given name argument.
|
||||||
|
*
|
||||||
|
* @param string name
|
||||||
|
* @param mixed default
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
get(name, defaultValue) {
|
||||||
|
if (this.has(name)) {
|
||||||
|
return this.args[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if (defaultValue !== undefined) {
|
||||||
* Return the value of the given name argument.
|
return defaultValue
|
||||||
*
|
|
||||||
* @param string name
|
|
||||||
* @param mixed default
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
get(name, defaultValue) {
|
|
||||||
if (this.has(name)) {
|
|
||||||
return this.args[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defaultValue !== undefined) {
|
|
||||||
return defaultValue
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* Check the given argument name exists.
|
}
|
||||||
*
|
|
||||||
* @param string name
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
has(name) {
|
|
||||||
return this.args.hasOwnProperty(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if args is empty.
|
* Check the given argument name exists.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @param string name
|
||||||
*/
|
*
|
||||||
empty() {
|
* @return boolean
|
||||||
return Object.keys(this.args).length === 1
|
*/
|
||||||
}
|
has(name) {
|
||||||
|
return this.args.hasOwnProperty(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if args is empty.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
empty() {
|
||||||
|
return Object.keys(this.args).length === 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Input
|
module.exports = Input
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
class Output {
|
class Output {
|
||||||
/**
|
/**
|
||||||
* Convert and print data to json.
|
* Convert and print data to json.
|
||||||
*
|
*
|
||||||
* @param mixed data
|
* @param mixed data
|
||||||
*/
|
*/
|
||||||
json(data, pretty) {
|
json(data, pretty) {
|
||||||
data = JSON.stringify(
|
data = JSON.stringify(
|
||||||
data,
|
data,
|
||||||
function(key, value) {
|
function(key, value) {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return value
|
return value
|
||||||
},
|
},
|
||||||
pretty ? 2 : null
|
pretty ? 2 : null
|
||||||
);
|
);
|
||||||
|
|
||||||
return this.write(data)
|
return this.write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print data.
|
* Print data.
|
||||||
*
|
*
|
||||||
* @param mixed data
|
* @param mixed data
|
||||||
*/
|
*/
|
||||||
write(data, level) {
|
write(data, level) {
|
||||||
level = level || 'log'
|
level = level || 'log'
|
||||||
|
|
||||||
console[level](data)
|
console[level](data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Output
|
module.exports = Output
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const filter = function(value) {
|
const filter = function(value) {
|
||||||
return value.replace(/(\n|\r)/g, '')
|
return value.replace(/(\n|\r)/g, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = filter
|
module.exports = filter
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const filter = function(value) {
|
const filter = function(value) {
|
||||||
return value.replace(/\s{2,}/g, ' ')
|
return value.replace(/\s{2,}/g, ' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = filter
|
module.exports = filter
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const striptags = require('striptags')
|
const striptags = require('striptags')
|
||||||
|
|
||||||
const filter = function(value, tags) {
|
const filter = function(value, tags) {
|
||||||
return striptags(value, tags)
|
return striptags(value, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = filter
|
module.exports = filter
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const trim = require('trim')
|
const trim = require('trim')
|
||||||
|
|
||||||
const filter = function(value) {
|
const filter = function(value) {
|
||||||
return trim(value)
|
return trim(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = filter
|
module.exports = filter
|
||||||
|
|
|
@ -2,19 +2,19 @@ const filter = require('../src/filter/breaks')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
|
||||||
describe('Check "breaks"', () => {
|
describe('Check "breaks"', () => {
|
||||||
it('Should return empty string', () => {
|
it('Should return empty string', () => {
|
||||||
assert.equal(filter("\n"), "")
|
assert.equal(filter("\n"), "")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return empty string', () => {
|
it('Should return empty string', () => {
|
||||||
assert.equal(filter("\r"), "")
|
assert.equal(filter("\r"), "")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return "foo"', () => {
|
it('Should return "foo"', () => {
|
||||||
assert.equal(filter("foo"), "foo")
|
assert.equal(filter("foo"), "foo")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return "foobar"', () => {
|
it('Should return "foobar"', () => {
|
||||||
assert.equal(filter("\r\nfoo\nbar\r\n"), "foobar")
|
assert.equal(filter("\r\nfoo\nbar\r\n"), "foobar")
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,15 +2,15 @@ const filter = require('../src/filter/spaces')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
|
||||||
describe('Check "spaces"', () => {
|
describe('Check "spaces"', () => {
|
||||||
it('Should return ""', () => {
|
it('Should return ""', () => {
|
||||||
assert.equal(filter(""), "")
|
assert.equal(filter(""), "")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return "foo bar"', () => {
|
it('Should return "foo bar"', () => {
|
||||||
assert.equal(filter("foo bar"), "foo bar")
|
assert.equal(filter("foo bar"), "foo bar")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return "foo bar"', () => {
|
it('Should return "foo bar"', () => {
|
||||||
assert.equal(filter("foo \nbar"), "foo bar")
|
assert.equal(filter("foo \nbar"), "foo bar")
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,19 +2,19 @@ const filter = require('../src/filter/trim')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
|
||||||
describe('Check "trim"', () => {
|
describe('Check "trim"', () => {
|
||||||
it('Should return ""', () => {
|
it('Should return ""', () => {
|
||||||
assert.equal(filter(""), "")
|
assert.equal(filter(""), "")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return ""', () => {
|
it('Should return ""', () => {
|
||||||
assert.equal(filter(" "), "")
|
assert.equal(filter(" "), "")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return "foo"', () => {
|
it('Should return "foo"', () => {
|
||||||
assert.equal(filter(" foo "), "foo")
|
assert.equal(filter(" foo "), "foo")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should return "foo bar"', () => {
|
it('Should return "foo bar"', () => {
|
||||||
assert.equal(filter(" foo bar \n"), "foo bar")
|
assert.equal(filter(" foo bar \n"), "foo bar")
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue