This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| email: "YOUR_EMAIL", | |
| password: "YOUR_PASSWORD" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const stateFarmModule = require("./scrape-state-farm.js"); | |
| const emailModule = require("./send-email.js"); | |
| stateFarmModule(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const transporter = nodemailer.createTransport(smtpTransport({ | |
| service: 'Gmail', | |
| host: 'smtp.gmail.com', | |
| port: 465, | |
| auth: { | |
| user: credentials.email, | |
| pass: credentials.password | |
| } | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| browser.close(); | |
| return arrayJobResults; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (numPages != 1) { | |
| await page.click(constants.STATE_FARM_NEXT_PAGE_SELECTOR); | |
| await page.waitFor(2000); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let jobListLength = await page.evaluate((sel) => { | |
| let jobSelectorID = document.getElementById(sel); | |
| let jobSelectorTagName = jobSelectorID.getElementsByTagName("li"); | |
| return jobSelectorTagName.length; | |
| }, JOB_SELECTOR_ID); |