Skip to content

Instantly share code, notes, and snippets.

View agithony's full-sized avatar
🤩
Follow me to see what I'm building

Anthony Dellavecchia agithony

🤩
Follow me to see what I'm building
View GitHub Profile
module.exports = {
email: "YOUR_EMAIL",
password: "YOUR_PASSWORD"
}
const page = await browser.newPage();
await page.goto("https://statefarm.csod.com/ats/careersite/search.aspx?site=1&c=statefarm");
await page.click("#ctl00_siteContent_widgetLayout_rptWidgets_ctl03_widgetContainer_ctl00_rptCustomFields_ctl02_customFieldWrapper > button");
await page.click("body > div > ul > li:nth-child(46) > label > span");
await page.click("#ctl00_siteContent_widgetLayout_rptWidgets_ctl03_widgetContainer_ctl00_rptCustomFields_ctl00_customFieldWrapper_ctl00_txtValue");
await page.keyboard.type("technology");
await page.click("#ctl00_siteContent_widgetLayout_rptWidgets_ctl03_widgetContainer_ctl00_btnSearch");
await page.waitFor(2000);
run().then((value) => {
let data = value.join("\r\n");
console.log(data);
fs.writeFile("state-farm-jobs.txt", data, function (err) {
console.log(constants.SUCCESS_STMT);
});
console.log("scrape-state-farm.js - created txt file")
emailModule();
});
const stateFarmModule = require("./scrape-state-farm.js");
const emailModule = require("./send-email.js");
stateFarmModule();
const transporter = nodemailer.createTransport(smtpTransport({
service: 'Gmail',
host: 'smtp.gmail.com',
port: 465,
auth: {
user: credentials.email,
pass: credentials.password
}
}));
run().then((value) => {
let data = value.join("\r\n");
console.log(data);
fs.writeFile("state-farm-jobs.txt", data, function (err) {
console.log(constants.SUCCESS_STMT);
});
});
browser.close();
return arrayJobResults;
}
if (numPages != 1) {
await page.click(constants.STATE_FARM_NEXT_PAGE_SELECTOR);
await page.waitFor(2000);
}
}
for (let i = 1; i <= jobListLength; i++) {
let jobSelector = LIST_JOB_SELECTOR.replace("INDEX", i)
let jobListing = await page.evaluate((sel) => {
return document.querySelector(sel).innerText;
}, jobSelector);
arrayJobResults.push(jobListing);
}
let jobListLength = await page.evaluate((sel) => {
let jobSelectorID = document.getElementById(sel);
let jobSelectorTagName = jobSelectorID.getElementsByTagName("li");
return jobSelectorTagName.length;
}, JOB_SELECTOR_ID);