第一步,下载代码,安装依赖:node
$ git clone https://github.com/xiongwilee/Techweekly.git $ cd Techweekly && npm install --registry=https://registry.npm.taobao.org
第二步,修改邮件配置config/config.mail.js
:git
module.exports = { "sender": { "host": "邮箱服务器host", "port": "邮箱服务器端口号", "auth": { "user": "邮箱地址", "pass": "邮箱密码" } }, "subject": "邮件主题", "from": "你的名字 <邮箱地址>", "to": ["收件人邮箱地址"] }
或者,你也能够直接使用默认的邮箱配置config.mail.sample.js
,修改config.mail.sample.js
为config.mail.js
github
第三步,发送周报邮件:npm
$ node index.js
FYI: 服务器
若是你须要定时发送邮件,推荐使用crontab
:url
* 10 * * 5 cd /your/project/path/ && node index.js
Techweekly默认支持fex和75team两个默认周报源,你能够根据本身的需求配置周报来源:spa
"源ID(能够配置任意字符)": { /** * 页面链接,能够是一个string, 也能够是function,若是是function则: * @return {String} 页面URL */ url: function() {}, /** * 经过url获取文章内容URL的方法 * @param {string} html 经过页面链接爬取到的页面html * @return {String} 从html中解析到的文章内容的连接 */ getLink: function(html) {}, /** * 经过文章内容的连接爬取到文章主体 * @param {String} html 经过文章内容的连接爬取到文章的html * @return {String} 文章主体部分的html */ getContent: function(html) {} }
FYI: code
在getLink
和getContent
方法里,你能够直接使用cheerio来解析DOM。htm