@easyscrape/core
Version:
EasyScrape is a NodeJS module designed to be integrated into your web scraping project. With it, you can more easily get information from the web from a JSON object to organized data, as a REST API could give you!
48 lines • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const _EasyScrapeCore_1 = require("..");
const mocha_1 = require("mocha");
const chai_1 = require("chai");
const IESObject_1 = tslib_1.__importDefault(require("../src/Interfaces/ITypes/IESObject.type"));
let scrape;
(0, chai_1.should)();
(0, mocha_1.describe)('Cheerio Middleware Test', () => {
(0, mocha_1.before)(() => {
const TestEasyScrape = new (class extends _EasyScrapeCore_1.AbstractEasyScrapeMiddleware {
constructor() {
super(...arguments);
this.SupportFor = { LibraryName: 'Test', PackageName: 'easyscrape-core' };
this.QueriesManager = new (class extends _EasyScrapeCore_1.AbstractESQueriesManager {
_select$($, param) {
return $[Number.parseInt(param, 10)];
}
_$ID$($, param) {
return $.testID;
}
})(this);
}
load($) {
return (query) => this.collect($, query);
}
canICollect($) {
return typeof $ === 'object' && typeof $.testID === 'number';
}
});
scrape = TestEasyScrape.load({
testID: 0,
0: { testID: 1 },
1: { testID: 2 },
2: { testID: 3 }
});
});
(0, mocha_1.it)('Test For Queries Module Support', () => {
const response = scrape({
_select: '0',
_getIDTest: true
});
response.should.be.a('number');
response.should.equal(1);
});
});
//# sourceMappingURL=index.test.js.map