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(), + }; +};