Skip to content

Instantly share code, notes, and snippets.

@agithony
Created March 21, 2018 01:42
Show Gist options
  • Select an option

  • Save agithony/2e7c8f1ab1fdb5bb5a05943c92aaef98 to your computer and use it in GitHub Desktop.

Select an option

Save agithony/2e7c8f1ab1fdb5bb5a05943c92aaef98 to your computer and use it in GitHub Desktop.
for (let h = 1; h <= numPages; h++) {
console.log("Page Number : " + h);
let jobListLength = await page.evaluate((sel) => {
let jobSelectorID = document.getElementById(sel);
let jobSelectorTagName = jobSelectorID.getElementsByTagName("li");
return jobSelectorTagName.length;
}, JOB_SELECTOR_ID);
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);
}
if (numPages != 1) {
await page.click(constants.STATE_FARM_NEXT_PAGE_SELECTOR);
await page.waitFor(2000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment