feat(route): add 超星期刊 (#8615)
This commit is contained in:
parent
dff523d194
commit
a8ee326fe7
|
|
@ -139,6 +139,32 @@ pageClass: routes
|
|||
|
||||
<Route author="CokeMine" example="/bookscomtw/newbooks/books_nbtopm_15" path="/bookscomtw/newbooks/:category" :paramsDesc="['书籍类型 category, 可在对应博客来新书页 URL 中找到']"/>
|
||||
|
||||
## 超星
|
||||
|
||||
### 期刊
|
||||
|
||||
<Route author="nczitzk" example="/chaoxing/qk/6b5c39b3dd84352be512e29df0297437" path="/chaoxing/qk/:id/:needContent?" :paramsDesc="['期刊 id,可在期刊页 URL 中找到', '需要获取文章全文,填写 true/yes 表示需要,默认需要']" anticrawler="1" radar="1" rssbud="1">
|
||||
|
||||
::: tip 看我
|
||||
|
||||
全部期刊可以在 [这里](http://qk.chaoxing.com/space/index) 找到,你也可以从 [学科分类](https://qikan.chaoxing.com/jourclassify) 和 [期刊导航](https://qikan.chaoxing.com/search/openmag) 中发现更多期刊。
|
||||
|
||||
如订阅 [**上海文艺**](http://m.chaoxing.com/mqk/list?sw=&mags=6b5c39b3dd84352be512e29df0297437&isort=20&from=space),其 URL 为 <http://m.chaoxing.com/mqk/list?mags=6b5c39b3dd84352be512e29df0297437>。`6b5c39b3dd84352be512e29df0297437` 即为期刊 id,所得路由为 [`/chaoxing/qk/6b5c39b3dd84352be512e29df0297437`](https://rsshub.app/chaoxing/qk/6b5c39b3dd84352be512e29df0297437)
|
||||
|
||||
:::
|
||||
|
||||
::: warning 提示
|
||||
|
||||
你可以设置参数 **需要获取文章全文** 为 `true` `yes` `t` `y` 等值(或者忽略这个参数),RSS 的条目会携带期刊中的 **文章全文**,而不仅仅是 **文章概要**。但因为发起访问请求过多会被该网站屏蔽,你可以将其关闭(设置该参数为 `false` `no` `f` `n` 等值),这将会大大减少请求次数从而更难触发网站的反爬机制。
|
||||
|
||||
路由默认会获取 **30** 个条目。在路由后指定 `?limit=<条目数量>` 减少或增加单次获取条目数量,同样可以减少请求次数,如设置为一次获取 **10** 个条目,路由可以更改为 [`/chaoxing/qk/6b5c39b3dd84352be512e29df0297437?limit=10`](https://rsshub.app/chaoxing/qk/6b5c39b3dd84352be512e29df0297437?limit=10)
|
||||
|
||||
在根据上文设置 **需要获取文章全文** 为不需要时,你可以将 `limit` 值增大,从而获取更多的条目,此时因为不获取全文也不会触发反爬机制,如 [`/chaoxing/qk/6b5c39b3dd84352be512e29df0297437/false?limit=100`](https://rsshub.app/chaoxing/qk/6b5c39b3dd84352be512e29df0297437/false?limit=100)
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 吹牛部落
|
||||
|
||||
### 栏目
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/qk/:id/:needContent?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const needContent = /t|y/i.test(ctx.params.needContent ?? 'true');
|
||||
|
||||
const rootUrl = 'http://m.chaoxing.com';
|
||||
const currentUrl = `${rootUrl}/mqk/json?size=${ctx.query.limit ?? 30}&mags=${id}&isort=20`;
|
||||
|
||||
const headers = {
|
||||
cookie: 'duxiu=userName_dsr%2C%3Dmmxy%2C!userid_dsr%2C%3D837%2C!enc_dsr%2C%3D7EDE234634FC80D554A7F6D1AA0D3629; AID_dsr=665; msign_dsr=1638170006420;',
|
||||
};
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
headers,
|
||||
});
|
||||
|
||||
let items = response.data.list.map((item) => ({
|
||||
title: item.infos.C301,
|
||||
author: item.infos.C303,
|
||||
link: item.infos.read,
|
||||
category: [item.infos.C314, item.infos.C031],
|
||||
pubDate: parseDate(item.infos.C103, 'YYYYMMDD'),
|
||||
description: art(path.join(__dirname, 'templates/description.art'), {
|
||||
description: (item.infos.M305 ?? item.infos.C305 ?? '').trim(),
|
||||
}),
|
||||
}));
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (needContent) {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
headers,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('#article_content').html() ?? content('body').html();
|
||||
}
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: response.data.list[0].infos.C307,
|
||||
link: `${rootUrl}/mqk/list?mags=${id}&isort=20&from=space`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'chaoxing.com': {
|
||||
_name: '超星',
|
||||
'.': [
|
||||
{
|
||||
title: '期刊',
|
||||
docs: 'https://docs.rsshub.app/reading.html#chao-xing-qi-kan',
|
||||
source: ['/'],
|
||||
target: (params, url) => `/chaoxing/qk/${new URL(url).searchParams.get('mags')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/qk/:id/:needContent?', require('./qk'));
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{{ if description }}
|
||||
<p>{{ description }}</p>
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue