Skip to content

Instantly share code, notes, and snippets.

@Josiassejod1
Created July 9, 2022 19:14
Show Gist options
  • Select an option

  • Save Josiassejod1/587440edcfbd4e90d65ee3f1f6f24fe6 to your computer and use it in GitHub Desktop.

Select an option

Save Josiassejod1/587440edcfbd4e90d65ee3f1f6f24fe6 to your computer and use it in GitHub Desktop.
Scraping Multiple Sites With Nightmare JS
const Nightmare = require("nightmare");
const nightmare = Nightmare();
const clientSites = ["google.com", "pbs.org", "espn.com"];
var _prefix = "https://www.";
(async () => {
for (var i = 0; i < clientSites.length; i++) {
const site = clientSites[i];
console.log(site)
await nightmare
.goto(_prefix + clientSites[i])
.wait()
.screenshot(`screenshots/${site}.png`)
.catch((error) => {
console.error("Search failed:", error);
});
}
await nightmare.end();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment