npm install @achannarasappa/locust
Define what data and where to find it rather than how
module.exports = job = {
extract: async ($) => ({
'title': await $('title'),
}),
url: 'http://ecommerce-site.com',
};
module.exports = job = {
...
// AWS Lambda
start: () => (new require('aws-sdk').Lambda()).invoke({
FunctionName: "locust-job",
InvocationType: "Event",
}),
// Google Cloud Functions
start: () => require('child_process').execSync('gcloud functions call locust-job'),
// Linux/Windows Process
start: () => require('child_process').execSync('node -e "(async () => require("./job").start(job))()"'),
// NodeJS
start: () => require('locust').execute(job),
...
};
module.exports = job = {
extract: async ($, page) => {
await page.waitFor('.profile');
return {
firstName: await $('.profile > .first_name'),
lastName: await $('.profile > .last_name'),
}
},
};