-
-
Save timarney/40aecbd9514b5e0dab01d7e8e88e653d to your computer and use it in GitHub Desktop.
Is landing page
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 puppeteer = require("puppeteer"); | |
const hrefLinks = async page => { | |
const hrefs = await page.$$eval("a", as => | |
as.map(a => { | |
return { text: a.innerHTML.toLowerCase(), link: a.href }; | |
}) | |
); | |
langs = []; | |
hrefs.map((item, index) => { | |
if (item.text == "english" || item.text == "français") { | |
langs.push(item.link); | |
} | |
}); | |
return langs; | |
}; | |
(async () => { | |
const startUrl = "https://candid.drdc-rddc.gc.ca"; | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto(startUrl); | |
await hrefLinks(page); | |
if (langs.length === 2) { | |
console.log("Yes is landing"); | |
page.goto(langs[0]); | |
await page.screenshot({ path: "example.png" }); | |
} | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment