feat: add queshu (#2850)

* feat: add queshu

* feat: add queshu
This commit is contained in:
Cloud
2019-08-14 17:34:21 +08:00
committed by DIYgod
parent 0f0297ea67
commit 17b4946c00
5 changed files with 64 additions and 0 deletions

View File

@@ -823,6 +823,16 @@ type 为 all 时category 参数不支持 cost 和 free
</Route> </Route>
## 缺书网
### 促销
<Route author="kt286" example="/queshu/sale" path="/queshu/sale"/>
### 单品活动信息
<Route author="kt286" example="/queshu/book/34626813" path="/queshu/book/:bookid" :paramsDesc="['图书ID可在链接中获取']"/>
## 人人都是产品经理 ## 人人都是产品经理
### 热门文章 ### 热门文章

View File

@@ -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('/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; module.exports = router;

22
lib/routes/queshu/book.js Normal file
View File

@@ -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')`,
},
});
};

27
lib/routes/queshu/sale.js Normal file
View File

@@ -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()
+ '<br>'
+ $('.news_sale_detail .sale_time_end').first().text()
+ '<br>'
+ '发布时间:' + $('.news_sale_detail .sale_time_end.inline_right').text()
`,
},
});
};

View File

@@ -45,6 +45,7 @@ async function buildData(data) {
return { return {
title: getProp(data, 'title', $), title: getProp(data, 'title', $),
description: getProp(data, 'description', $), description: getProp(data, 'description', $),
allowEmpty: data.allowEmpty || false,
item: $item item: $item
.map((_, e) => { .map((_, e) => {
const $elem = (selector) => $(e).find(selector); const $elem = (selector) => $(e).find(selector);