From 40d425988ed10eea64fb70fc881fb89af80bd6e3 Mon Sep 17 00:00:00 2001
From: wushijishan <65406369+wushijishan@users.noreply.github.com>
Date: Sun, 28 Jun 2020 11:32:03 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EBOOKWALKER=E5=8F=B0?=
=?UTF-8?q?=E6=B9=BE=E7=AB=99=E6=96=B0=E4=B8=8A=E6=9E=B6=E4=B9=A6=E7=B1=8D?=
=?UTF-8?q?=20(#5071)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/other.md | 6 ++++++
lib/router.js | 3 +++
lib/routes/bookwalkertw/news.js | 32 ++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
create mode 100644 lib/routes/bookwalkertw/news.js
diff --git a/docs/other.md b/docs/other.md
index eda29a377..8722fd264 100644
--- a/docs/other.md
+++ b/docs/other.md
@@ -727,3 +727,9 @@ type 为 all 时,category 参数不支持 cost 和 free
### はてな匿名ダイアリー - 人気記事アーカイブ
+
+## BOOKWALKERTW
+
+### 热门新书
+
+
\ No newline at end of file
diff --git a/lib/router.js b/lib/router.js
index 3af5311e2..fb2541e9f 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -2874,6 +2874,9 @@ router.get('/changku', require('./routes/changku/index'));
// 上海市生态环境局
router.get('/gov/shanghai/sthj', require('./routes/gov/shanghai/sthj'));
+// BookwalkerTW热门新书
+router.get('/bookwalkertw/news', require('./routes/bookwalkertw/news'));
+
// Amazfit Watch Faces
router.get('/amazfitwatchfaces/fresh/:model/:type?/:lang?', require('./routes/amazfitwatchfaces/fresh'));
router.get('/amazfitwatchfaces/updated/:model/:type?/:lang?', require('./routes/amazfitwatchfaces/updated'));
diff --git a/lib/routes/bookwalkertw/news.js b/lib/routes/bookwalkertw/news.js
new file mode 100644
index 000000000..6e7a0dda6
--- /dev/null
+++ b/lib/routes/bookwalkertw/news.js
@@ -0,0 +1,32 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+
+module.exports = async (ctx) => {
+ const response = await got({
+ method: 'get',
+ url: 'https://www.bookwalker.com.tw/more/index/1',
+ });
+
+ const data = response.data;
+
+ const $ = cheerio.load(data);
+ const list = $('div[class="bwbookitem"]');
+ let bookid;
+ ctx.state.data = {
+ title: 'BOOKWALKERTW热门新书',
+ link: 'https://www.bookwalker.com.tw/more/index/1',
+ item:
+ list &&
+ list
+ .map((index, item) => {
+ item = $(item);
+ bookid = item.find('a').attr('href').substring(38, 43);
+ return {
+ title: item.find('.bookname').text(),
+ description: `${item.find('.booknamesub').text()} | ${item.find('.bprice').text()}
`,
+ link: item.find('a').attr('href'),
+ };
+ })
+ .get(),
+ };
+};