@skypilot/scraper
Version:
Node-based scriptable web scraper
61 lines (56 loc) • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.builder = exports.commands = void 0;
var _ScriptBuilder = require("../scraper/ScriptBuilder");
const collectionName = 'domains';
const commands = [{
action: 'goTo',
url: 'https://www.iana.org/domains/reserved'
}, {
action: 'runOnAll',
query: {
sel: 'table#arpa-table > tbody > tr > td > span.domain.label',
limit: 3
},
commands: [{
action: 'follow',
query: {
sel: 'a'
}
}, {
action: 'query',
queryDict: {
title: {
sel: 'head > title'
},
sponsor: toCellSelector('Sponsoring Organisation'),
adminContact: toCellSelector('Administrative Contact'),
techContact: toCellSelector('Technical Contact')
}
}, {
action: 'write'
}],
options: {
collectionName
}
}];
exports.commands = commands;
function toCellSelector(label) {
return {
sel: `//h2[contains(text(), '${label}')]/following-sibling::b`
};
}
const builder = new _ScriptBuilder.ScriptBuilder().goTo('https://www.iana.org/domains/reserved').runOnAll({
sel: 'table#arpa-table > tbody > tr > td > span.domain.label',
limit: 3
}, new _ScriptBuilder.ScriptBuilder().follow('a').query({
title: 'head > title',
sponsor: toCellSelector('Sponsoring Organisation'),
adminContact: toCellSelector('Administrative Contact'),
techContact: toCellSelector('Technical Contact')
}).write(), {
collectionName
});
exports.builder = builder;