Created
July 9, 2022 19:14
-
-
Save Josiassejod1/587440edcfbd4e90d65ee3f1f6f24fe6 to your computer and use it in GitHub Desktop.
Scraping Multiple Sites With Nightmare JS
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 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