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
|
||||
=======
|
||||
|
||||
[![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
|
||||
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",
|
||||
"main": "src/index.js",
|
||||
"devDependencies": {
|
||||
"mocha": "^8.1.3"
|
||||
"mocha": "^10.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cheerio": "^1.0.0-rc.3",
|
||||
"extends-classes": "^1.0.5",
|
||||
"minimist": "^1.2.5",
|
||||
"request": "^2.88.2",
|
||||
"request-promise": "^4.2.5",
|
||||
"request-promise": "^4.2.6",
|
||||
"striptags": "^3.1.1",
|
||||
"trim": "^0.0.1"
|
||||
"trim": "^1.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
|
|
|
@ -3,56 +3,56 @@
|
|||
var Minimist = require('minimist');
|
||||
|
||||
class Input {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object process
|
||||
*/
|
||||
constructor(process) {
|
||||
this.args = Minimist(process.argv.slice(2))
|
||||
this.node = process.argv[0]
|
||||
this.script = process.argv[1]
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object process
|
||||
*/
|
||||
constructor(process) {
|
||||
this.args = Minimist(process.argv.slice(2))
|
||||
this.node = process.argv[0]
|
||||
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]
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 defaultValue
|
||||
}
|
||||
|
||||
return null;
|
||||
if (defaultValue !== undefined) {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the given argument name exists.
|
||||
*
|
||||
* @param string name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
has(name) {
|
||||
return this.args.hasOwnProperty(name)
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if args is empty.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
empty() {
|
||||
return Object.keys(this.args).length === 1
|
||||
}
|
||||
/**
|
||||
* Check the given argument name exists.
|
||||
*
|
||||
* @param string name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
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
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
"use strict";
|
||||
|
||||
class Output {
|
||||
/**
|
||||
* Convert and print data to json.
|
||||
*
|
||||
* @param mixed data
|
||||
*/
|
||||
json(data, pretty) {
|
||||
data = JSON.stringify(
|
||||
data,
|
||||
function(key, value) {
|
||||
if (value === undefined) {
|
||||
return null
|
||||
}
|
||||
/**
|
||||
* Convert and print data to json.
|
||||
*
|
||||
* @param mixed data
|
||||
*/
|
||||
json(data, pretty) {
|
||||
data = JSON.stringify(
|
||||
data,
|
||||
function(key, value) {
|
||||
if (value === undefined) {
|
||||
return null
|
||||
}
|
||||
|
||||
return value
|
||||
},
|
||||
pretty ? 2 : null
|
||||
);
|
||||
return value
|
||||
},
|
||||
pretty ? 2 : null
|
||||
);
|
||||
|
||||
return this.write(data)
|
||||
}
|
||||
return this.write(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Print data.
|
||||
*
|
||||
* @param mixed data
|
||||
*/
|
||||
write(data, level) {
|
||||
level = level || 'log'
|
||||
/**
|
||||
* Print data.
|
||||
*
|
||||
* @param mixed data
|
||||
*/
|
||||
write(data, level) {
|
||||
level = level || 'log'
|
||||
|
||||
console[level](data)
|
||||
}
|
||||
console[level](data)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Output
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const filter = function(value) {
|
||||
return value.replace(/(\n|\r)/g, '')
|
||||
return value.replace(/(\n|\r)/g, '')
|
||||
}
|
||||
|
||||
module.exports = filter
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const filter = function(value) {
|
||||
return value.replace(/\s{2,}/g, ' ')
|
||||
return value.replace(/\s{2,}/g, ' ')
|
||||
}
|
||||
|
||||
module.exports = filter
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const striptags = require('striptags')
|
||||
|
||||
const filter = function(value, tags) {
|
||||
return striptags(value, tags)
|
||||
return striptags(value, tags)
|
||||
}
|
||||
|
||||
module.exports = filter
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const trim = require('trim')
|
||||
|
||||
const filter = function(value) {
|
||||
return trim(value)
|
||||
return trim(value)
|
||||
}
|
||||
|
||||
module.exports = filter
|
||||
|
|
|
@ -2,19 +2,19 @@ const filter = require('../src/filter/breaks')
|
|||
const assert = require('assert')
|
||||
|
||||
describe('Check "breaks"', () => {
|
||||
it('Should return empty string', () => {
|
||||
assert.equal(filter("\n"), "")
|
||||
})
|
||||
it('Should return empty string', () => {
|
||||
assert.equal(filter("\n"), "")
|
||||
})
|
||||
|
||||
it('Should return empty string', () => {
|
||||
assert.equal(filter("\r"), "")
|
||||
})
|
||||
it('Should return empty string', () => {
|
||||
assert.equal(filter("\r"), "")
|
||||
})
|
||||
|
||||
it('Should return "foo"', () => {
|
||||
assert.equal(filter("foo"), "foo")
|
||||
})
|
||||
it('Should return "foo"', () => {
|
||||
assert.equal(filter("foo"), "foo")
|
||||
})
|
||||
|
||||
it('Should return "foobar"', () => {
|
||||
assert.equal(filter("\r\nfoo\nbar\r\n"), "foobar")
|
||||
})
|
||||
it('Should return "foobar"', () => {
|
||||
assert.equal(filter("\r\nfoo\nbar\r\n"), "foobar")
|
||||
})
|
||||
});
|
||||
|
|
|
@ -2,15 +2,15 @@ const filter = require('../src/filter/spaces')
|
|||
const assert = require('assert')
|
||||
|
||||
describe('Check "spaces"', () => {
|
||||
it('Should return ""', () => {
|
||||
assert.equal(filter(""), "")
|
||||
})
|
||||
it('Should return ""', () => {
|
||||
assert.equal(filter(""), "")
|
||||
})
|
||||
|
||||
it('Should return "foo bar"', () => {
|
||||
assert.equal(filter("foo bar"), "foo bar")
|
||||
})
|
||||
it('Should return "foo bar"', () => {
|
||||
assert.equal(filter("foo bar"), "foo bar")
|
||||
})
|
||||
|
||||
it('Should return "foo bar"', () => {
|
||||
assert.equal(filter("foo \nbar"), "foo bar")
|
||||
})
|
||||
it('Should return "foo bar"', () => {
|
||||
assert.equal(filter("foo \nbar"), "foo bar")
|
||||
})
|
||||
});
|
||||
|
|
|
@ -2,19 +2,19 @@ const filter = require('../src/filter/trim')
|
|||
const assert = require('assert')
|
||||
|
||||
describe('Check "trim"', () => {
|
||||
it('Should return ""', () => {
|
||||
assert.equal(filter(""), "")
|
||||
})
|
||||
it('Should return ""', () => {
|
||||
assert.equal(filter(""), "")
|
||||
})
|
||||
|
||||
it('Should return ""', () => {
|
||||
assert.equal(filter(" "), "")
|
||||
})
|
||||
it('Should return ""', () => {
|
||||
assert.equal(filter(" "), "")
|
||||
})
|
||||
|
||||
it('Should return "foo"', () => {
|
||||
assert.equal(filter(" foo "), "foo")
|
||||
})
|
||||
it('Should return "foo"', () => {
|
||||
assert.equal(filter(" foo "), "foo")
|
||||
})
|
||||
|
||||
it('Should return "foo bar"', () => {
|
||||
assert.equal(filter(" foo bar \n"), "foo bar")
|
||||
})
|
||||
it('Should return "foo bar"', () => {
|
||||
assert.equal(filter(" foo bar \n"), "foo bar")
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue