forked from Zubogain/udemy-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (28 loc) · 824 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
import chalk from "chalk";
import sleep from "sleep";
import { userAgents, viewports } from "./browser-settings";
import { PuppeteerHandler } from "./helpers";
import { readLanguages, initCatsDir, getSavedCats } from "./common";
import { toXLSX } from "./convert";
const SITE = "https://www.udemy.com/";
(async function main() {
initCatsDir();
const p = new PuppeteerHandler(
SITE,
userAgents[0],
viewports[0],
readLanguages(getSavedCats())
);
try {
await p.start();
console.log(chalk.white.underline("Data scraping finished!"));
p.closeBrowser();
toXLSX();
} catch (err) {
console.log(chalk.red("An error has occured:", chalk.yellow(err)));
console.log(chalk.white.bgBlack("Parser is restarting..."));
p.closeBrowser();
sleep.msleep(10000);
main();
}
})();