Pull posts of https://www.pluralsight.com
-
run
npm init -y, create a default package.json file in your project's root folder. -
install typescript use
npm i -D typescript. -
initialize typescript config file.
tsc --initor if you never install typescript at global, you can run this command through./node_modules/typescript/bin/tsc --init, then you'll see thetsconfig.jsonfile created in root path. -
make a folder named
src, all our source code will stay at this folder. -
we need tools to fetch html page, run
npm i superagent, and for analyzing raw html, runnpm i cheerioto install cheerio. -
fix types error, run
npm i @types/superagent @types/cheerio -D. -
open package.json, add some necessary scripts.
"build": "tsc", "dev": "ts-node ./src/main.ts",npm i ts-node -Dfor local developing. -
complete the crawler code, then run
npm run dev, all posts will be collected and generate a json file nameddata.jsonin root path.