Install this globally. Yes, globally.
$ npm install -g scrape-html
Now create a local project somewhere:
$ cd free_the_books
$ npm init
$ npm install --save node-slack scrape-html
Copy in index.js from below and fill in your slack webhook config. Schedule it to run with cron:
$ crontab -e
I have mine setup to run at 9am, which looks like the following. If you need help learning cron snytax I like http://crontab.guru
0 9 * * * /usr/local/bin/node /Users/atcodes/DEV/free_the_books/index.js
By default node wants to install globals into /usr/local/lib/node_modules/
(and this is why you probably have to sudo
every time you install a global). If you've wisely changed your default install location, this is how you adjust for it:
Your crontab line will need to set the environment variable NODE_PATH
before executing the program. Change it to look like the following:
0 9 * * * NODE_PATH=NODE_PATH=/Users/atcodes/.npm_globals/lib/node_modules/scrape-html/node_modules/ /usr/local/bin/node /Users/atcodes/DEV/free_the_books/index.js
Note that in the example above, my username is atcodes
and I install node globals to ~/.npm_globals/