mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add Kindle Unlimited会员限时免费读书单 (#6031)
Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
@@ -10,6 +10,18 @@ pageClass: routes
|
||||
|
||||
<Route author="HenryQW" example="/allpoetry/newest" path="/allpoetry/:order?" :paramsDesc="['排序方式, `best` 或 `newest`, 缺省 `best`']"/>
|
||||
|
||||
## Kindle Unlimited
|
||||
|
||||
### 会员限时免费读书单
|
||||
|
||||
<Route author="nczitzk" example="/amazon/ku/this" path="/amazon/ku/:type?" :paramsDesc="['书单类型,见下表']">
|
||||
|
||||
| 本月书单 | 好评返场 | 次月预告 |
|
||||
| -------- | -------- | -------- |
|
||||
| this | back | next |
|
||||
|
||||
</Route>
|
||||
|
||||
## Mobilism
|
||||
|
||||
### eBook Releases
|
||||
|
||||
@@ -3384,6 +3384,9 @@ router.get('/dev.to/top/:period', require('./routes/dev.to/top'));
|
||||
router.get('/gameres/hot', require('./routes/gameres/hot'));
|
||||
router.get('/gameres/list/:id', require('./routes/gameres/list'));
|
||||
|
||||
// Amazon
|
||||
router.get('/amazon/ku/:type?', require('./routes/amazon/ku'));
|
||||
|
||||
// Citavi 中文网站论坛
|
||||
router.get('/citavi/:caty?', require('./routes/citavi/index'));
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const config = {
|
||||
this: '2037295071',
|
||||
back: '2330861071',
|
||||
next: '2037296071',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 'this';
|
||||
|
||||
const node = config[type];
|
||||
if (!node) {
|
||||
throw Error('Bad type. See <a href="https://docs.rsshub.app/reading.html#kindle-unlimited-hui-yuan-xian-shi-mian-fei-du-shu-dan">docs</a>');
|
||||
}
|
||||
|
||||
const rootUrl = `https://www.amazon.cn/b?node=${node}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.s-access-detail-page')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
link: item.attr('href'),
|
||||
title: item.attr('title'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.author = content('span.author').text();
|
||||
item.description = content('#ebooks-img-canvas').html() + content('#detailBullets_feature_div').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `KU会员限时免费读 - ${$('title').text().split('-')[1]}`,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user