diff --git a/docs/other.md b/docs/other.md index 9d7240a93c..1d29212d19 100644 --- a/docs/other.md +++ b/docs/other.md @@ -823,6 +823,16 @@ type 为 all 时,category 参数不支持 cost 和 free +## 缺书网 + +### 促销 + + + +### 单品活动信息 + + + ## 人人都是产品经理 ### 热门文章 diff --git a/lib/router.js b/lib/router.js index cdb8fe61ad..acd5535ed9 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1654,4 +1654,8 @@ router.get('/wechat-open/pay/announce', require('./routes/wechat-open/pay/announ // 币世界快讯 router.get('/bishijie/kuaixun', require('./routes/bishijie/kuaixun')); +// 缺书网 +router.get('/queshu/sale', require('./routes/queshu/sale')); +router.get('/queshu/book/:bookid', require('./routes/queshu/book')); + module.exports = router; diff --git a/lib/routes/queshu/book.js b/lib/routes/queshu/book.js new file mode 100644 index 0000000000..824acf2823 --- /dev/null +++ b/lib/routes/queshu/book.js @@ -0,0 +1,22 @@ +const buildData = require('@/utils/common-config'); + +module.exports = async (ctx) => { + const bookid = ctx.params.bookid; + const link = `http://www.queshu.com/book/${bookid}`; + const host = `http://www.queshu.com`; + ctx.state.data = await buildData({ + link, + url: link, + title: `%title%`, + allowEmpty: true, + params: { + title: '单品活动信息 - 缺书网', + host, + }, + item: { + item: '.stacked.right_state a', + title: `$('.right_item .bodycol_258').text()`, + link: `'%host%' + $('.right_item').parent().attr('href')`, + }, + }); +}; diff --git a/lib/routes/queshu/sale.js b/lib/routes/queshu/sale.js new file mode 100644 index 0000000000..057e796e95 --- /dev/null +++ b/lib/routes/queshu/sale.js @@ -0,0 +1,27 @@ +const buildData = require('@/utils/common-config'); + +module.exports = async (ctx) => { + const link = `http://www.queshu.com/sale/`; + const host = `http://www.queshu.com`; + ctx.state.data = await buildData({ + link, + url: link, + title: `%title%`, + params: { + title: '图书促销 - 缺书网', + host, + }, + item: { + item: '#tb_sale tr', + title: `$('.news_sale_detail .sale_btn').text() + ':' + $('.news_sale_title a').text()`, + link: `'%host%' + $('.news_sale_title a').attr('href')`, + description: `$('.news_sale_detail .sale_btn').text() + ':' + $('.news_sale_title a').text() + + '
' + + $('.news_sale_detail .sale_time_end').first().text() + + '
' + + '发布时间:' + $('.news_sale_detail .sale_time_end.inline_right').text() + + `, + }, + }); +}; diff --git a/lib/utils/common-config.js b/lib/utils/common-config.js index 5ec1cbeebc..50ac842e91 100644 --- a/lib/utils/common-config.js +++ b/lib/utils/common-config.js @@ -45,6 +45,7 @@ async function buildData(data) { return { title: getProp(data, 'title', $), description: getProp(data, 'description', $), + allowEmpty: data.allowEmpty || false, item: $item .map((_, e) => { const $elem = (selector) => $(e).find(selector);