fix & optimize
This commit is contained in:
@ -20,11 +20,15 @@ async function extract(itemsSelector, fieldSelectors, ...args) {
|
||||
* @param {...any} args url list / url templates, page numers, either [from, to, interval] or [...pages]
|
||||
*/
|
||||
async function getData(itemsSelector, fieldSelectors, ...args) {
|
||||
if (!testArgs(itemsSelector, fieldSelectors, ...args))
|
||||
throw new Error(`Invalid call arguments.\n\n${signitures}\n\n`);
|
||||
let urls = [];
|
||||
if (args.length) {
|
||||
let arg = args.shift();
|
||||
if (arg instanceof Array) {
|
||||
urls = arg;
|
||||
} else if (arg instanceof ExractResult) {
|
||||
urls = arg.column(0);
|
||||
} else {
|
||||
let urlTempl = arg;
|
||||
if (urlTempl) {
|
||||
@ -62,7 +66,7 @@ async function getData(itemsSelector, fieldSelectors, ...args) {
|
||||
pms.then(
|
||||
results => {
|
||||
data.push(...results);
|
||||
resolve(new CSV(data));
|
||||
resolve(new ExractResult(data));
|
||||
},
|
||||
err => reject(err)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user