From d6fccdeeac290aacc8e1017023274153a1c6b910 Mon Sep 17 00:00:00 2001 From: Cloud Date: Thu, 15 Aug 2019 22:19:00 +0800 Subject: [PATCH] feat: queshu title add book name (#2862) --- docs/other.md | 10 ---------- docs/shopping.md | 10 ++++++++++ lib/routes/queshu/book.js | 2 +- lib/routes/queshu/sale.js | 1 + lib/utils/common-config.js | 3 +++ 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/other.md b/docs/other.md index 1d29212d1..9d7240a93 100644 --- a/docs/other.md +++ b/docs/other.md @@ -823,16 +823,6 @@ type 为 all 时,category 参数不支持 cost 和 free -## 缺书网 - -### 促销 - - - -### 单品活动信息 - - - ## 人人都是产品经理 ### 热门文章 diff --git a/docs/shopping.md b/docs/shopping.md index 2f53cc96f..8ba4116c1 100644 --- a/docs/shopping.md +++ b/docs/shopping.md @@ -48,6 +48,16 @@ pageClass: routes +## 缺书网 + +### 促销 + + + +### 单品活动信息 + + + ## 什么值得买 ::: tip 提示 diff --git a/lib/routes/queshu/book.js b/lib/routes/queshu/book.js index 824acf282..eb54aa4ed 100644 --- a/lib/routes/queshu/book.js +++ b/lib/routes/queshu/book.js @@ -10,7 +10,7 @@ module.exports = async (ctx) => { title: `%title%`, allowEmpty: true, params: { - title: '单品活动信息 - 缺书网', + title: `$('#book_left > #h1').text().trim() + ' - 单品活动信息 - 缺书网'`, host, }, item: { diff --git a/lib/routes/queshu/sale.js b/lib/routes/queshu/sale.js index 057e796e9..1a2a0ea58 100644 --- a/lib/routes/queshu/sale.js +++ b/lib/routes/queshu/sale.js @@ -22,6 +22,7 @@ module.exports = async (ctx) => { + '发布时间:' + $('.news_sale_detail .sale_time_end.inline_right').text() `, + pubDate: `date($('.news_sale_detail .sale_time_end.inline_right').text())`, }, }); }; diff --git a/lib/utils/common-config.js b/lib/utils/common-config.js index 50ac842e9..8e4583fc7 100644 --- a/lib/utils/common-config.js +++ b/lib/utils/common-config.js @@ -2,6 +2,8 @@ const cheerio = require('cheerio'); const got = require('@/utils/got'); // eslint-disable-next-line no-unused-vars const { addNoReferrer } = require('@/utils/common-utils'); +// eslint-disable-next-line no-unused-vars +const date = require('@/utils/date'); function transElemText($, prop) { const regex = new RegExp(/\$\((.*)\)/g); @@ -43,6 +45,7 @@ async function buildData(data) { const $item = $(data.item.item); // 这里应该是可以通过参数注入一些代码的,不过应该无伤大雅 return { + link: data.link, title: getProp(data, 'title', $), description: getProp(data, 'description', $), allowEmpty: data.allowEmpty || false,