在网上看到 分享一个自己写的github-trending小工具,感觉挺有趣的,自己也经常去看 Github 的 Trending。文章中是使用 Python 实现的,而我最近在学习 NodeJS,就使用 NodeJS 来实现。
直接使用 node 运行,但这样 shell 就不能关闭,并且如果出现异常就不能自动重启。
# install dependencies
npm install
# run scraper.js
node scraper.js
PM2 是一个带有负载均衡功能的Node应用的进程管理器。
# install pm2
npm install -g pm2
# pm2 start scraper.js
pm2 start scraper.js
根据日期重新生成。
node scraper.js 2017-10-28 2017
- tmpvar/jsdom 解析页面信息
- node-schedule/node-schedule 定时任务
- PM2 进程管理器
- Moment.js 轻量级时间格式化组件
- caolan/async: Async utilities for node and the browser 异步转同步