|
|
@ -34,7 +34,8 @@ Optional parameters |
|
|
|
--method [METHOD] HTTP Method |
|
|
|
--accept-http-error Accepts all status codes (like 404) |
|
|
|
|
|
|
|
--verbose, -v Show message of error |
|
|
|
--verbose, -v Show message of error |
|
|
|
--multiple, -m The output must contain all the selector targets |
|
|
|
`
|
|
|
|
|
|
|
|
if (input.has('help')) { |
|
|
@ -62,6 +63,7 @@ const selector = input.get('selector') |
|
|
|
const method = input.has('method') ? input.get('method') : 'GET' |
|
|
|
const acceptAllStatus = input.has('accept-http-error') |
|
|
|
const verbose = input.has('verbose') || input.has('v') |
|
|
|
const isMultiple = input.has('multiple') || input.has('m') |
|
|
|
|
|
|
|
let filtersToApply = {} |
|
|
|
|
|
|
@ -86,7 +88,13 @@ const options = { |
|
|
|
} |
|
|
|
|
|
|
|
const onSuccess = function(value) { |
|
|
|
output.write(value) |
|
|
|
if (isMultiple && value instanceof Array) { |
|
|
|
for (let item of value) { |
|
|
|
output.write(item) |
|
|
|
} |
|
|
|
} else { |
|
|
|
output.write(value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const onError = function(error) { |
|
|
@ -99,4 +107,4 @@ const onError = function(error) { |
|
|
|
process.exit(1) |
|
|
|
} |
|
|
|
|
|
|
|
scraper(options, selector, filtersToApply, onSuccess, onError) |
|
|
|
scraper(options, selector, filtersToApply, onSuccess, onError, isMultiple) |