第一步,下載代碼,安裝依賴: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