feat(route): add 起点图 (#8726)
This commit is contained in:
@@ -313,6 +313,28 @@ count 的取值范围为 1-12,为防止请求次数过多,推荐设置为 5
|
||||
|
||||
<Route author="LogicJake" example="/qidian/free-next" path="/qidian/free-next/:type?" :paramsDesc="['默认不填为起点中文网,填 mm 为起点女生网']"/>
|
||||
|
||||
## 起点图
|
||||
|
||||
### 首订
|
||||
|
||||
<Route author="nczitzk" example="/qidiantu/shouding" path="/qidiantu/shouding"/>
|
||||
|
||||
### 榜单
|
||||
|
||||
<Route author="nczitzk" example="/qidiantu" path="/qidiantu/:category?/:type?/:is_history?" :paramsDesc="['分类', '类型', '是否查看历史榜单,填写 true/yes 表示是,默认否']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
参数 **是否查看历史榜单** 设置为 `true` `yes` `t` `y` 等值后,RSS 会返回历史榜单。
|
||||
|
||||
如 [`/qidiantu/1/1/t`](https://rsshub.app/qidiantu/1/1/t) 将会返回 [起点首页 - 封推 的历史推荐记录](https://www.qidiantu.com/bang/1/1/) 的结果。
|
||||
|
||||
而 [`/qidiantu/1/1`](https://rsshub.app/qidiantu/1/1) 将会返回最新一期 [收藏增长 (起点首页 - 封推)](https://www.qidiantu.com/bang/1/1/2021-12-14) 的结果(编写文档时最新一期为 2021-12-14)。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 青空文庫
|
||||
|
||||
### 青空文庫新着リスト
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'shouding';
|
||||
const type = ctx.params.type ?? (category === 'shouding' ? '' : '1');
|
||||
const isHistory = /t|y/i.test(ctx.params.is_history ?? 'false');
|
||||
|
||||
const today = new Date();
|
||||
today.setTime(new Date().getTime() - 24 * 60 * 60 * 1000);
|
||||
const yesterday = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
|
||||
|
||||
const rootUrl = 'https://www.qidiantu.com';
|
||||
const currentUrl = `${rootUrl}/${category === 'shouding' ? `${category}/` : `bang/${category}/${type}/${isHistory ? '' : yesterday}`}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('a[role="button"]').remove();
|
||||
|
||||
let items = $(isHistory ? 'ul li a' : 'tbody tr')
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 25)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return isHistory
|
||||
? {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
}
|
||||
: {
|
||||
author: item.find('td').eq(3).text(),
|
||||
title: item.find('td[value]').first().text(),
|
||||
link: `${rootUrl}${item.find('td a').first().attr('href').replace(/\/d$/, '')}`,
|
||||
category: item
|
||||
.find(`td${category === 'shouding' ? '[value]' : ''}`)
|
||||
.eq(1)
|
||||
.text(),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(isHistory ? item.link : `${item.link}-${yesterday}`, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('#demo').next().remove();
|
||||
|
||||
if (isHistory) {
|
||||
item.description = content('.table-responsive').html();
|
||||
item.pubDate = parseDate(item.link.split('/').pop());
|
||||
} else {
|
||||
item.description = content('.media').html() + content('.panel-body').html();
|
||||
item.pubDate = timezone(
|
||||
parseDate(
|
||||
content('tbody tr')
|
||||
.last()
|
||||
.text()
|
||||
.match(/刷新时间:(\d{4}-\d{2}-\d{2} \d{2}:\d{2})/)[1]
|
||||
),
|
||||
+8
|
||||
);
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('.panel-heading').text()} - 起点图`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/:category?/:type?/:is_history?': ['nczitzk'],
|
||||
'/shouding': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'qidiantu.com': {
|
||||
_name: '起点图',
|
||||
'.': [
|
||||
{
|
||||
title: '首订',
|
||||
docs: 'https://docs.rsshub.app/reading.html#qi-dian-tu-shou-ding',
|
||||
source: ['/shouding', '/'],
|
||||
target: '/qidiantu/shouding',
|
||||
},
|
||||
{
|
||||
title: '榜单',
|
||||
docs: 'https://docs.rsshub.app/reading.html#qi-dian-tu-bang-dan',
|
||||
source: ['/bang/:category/:type', '/'],
|
||||
target: '/qidiantu/:category?/:type?/:is_history?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:category?/:type?/:is_history?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user