-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (31 loc) · 1006 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const puppeteer = require("puppeteer");
const { read } = require("./helpers/files");
const { scrape } = require("./src/scrape");
async function main() {
console.clear();
console.log("==================================");
console.log(" ★ intelligenerator/ad-scraper ★");
console.log("==================================");
const browser = await puppeteer.launch();
const sites = JSON.parse(await read("../config/sites.json"));
for (const siteInfo of sites) {
const page = await browser.newPage();
await page.setViewport({ width: 3840, height: 2160 });
try {
await scrape(page, siteInfo);
} catch (e) {
console.error(
`An error occurred while scraping ${siteInfo.name}: ${e}`
);
} finally {
await page.close();
}
}
console.log("Done!");
await browser.close();
}
try {
main();
} catch (e) {
console.error(`A general error occured: ${e}`);
}