mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add bjsk (#11787)
* feat(route): add bjsk * fix: add author
This commit is contained in:
@@ -44,6 +44,22 @@ pageClass: routes
|
||||
|
||||
<Route author="Fatpandac" example="/ssm/news" path="/ssm/news"/>
|
||||
|
||||
## 北京社科网
|
||||
|
||||
### 通用
|
||||
|
||||
<Route author="TonyRL" example="/bjsk/newslist-1394-1474-0" path="/bjsk/:path?" :paramsDesc="['路径,默认为 `newslist-1486-0-0`']" radar="1">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
路径处填写对应页面 URL 中 `https://www.bjsk.org.cn/` 和 `.html` 之间的字段。下面是一个例子。
|
||||
|
||||
若订阅 [社科资讯 > 社科要闻](https://www.bjsk.org.cn/newslist-1394-1474-0.html) 则将对应页面 URL <https://www.bjsk.org.cn/newslist-1394-1474-0.html> 中 `https://www.bjsk.org.cn/` 和 `.html` 之间的字段 `newslist-1394-1474-0` 作为路径填入。此时路由为 [`/bjsk/newslist-1394-1474-0`](https://rsshub.app/bjsk/newslist-1394-1474-0)
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 北京市保障房中心有限公司
|
||||
|
||||
### 北京市共有产权住房租赁服务平台
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const baseUrl = 'https://www.bjsk.org.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { path = 'newslist-1486-0-0' } = ctx.params;
|
||||
const link = `${baseUrl}/${path}.html`;
|
||||
const { data: response } = await got(link, {
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('.article-list a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.attr('title'),
|
||||
link: `${baseUrl}${item.attr('href')}`,
|
||||
pubDate: parseDate(item.find('.time').text(), 'YYYY.MM.DD'),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link, {
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response);
|
||||
item.description = $('.article-main').html();
|
||||
item.author = $('.info')
|
||||
.text()
|
||||
.match(/作者:(.*)\s+来源/)[1];
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
image: 'https://www.bjsk.org.cn/favicon.ico',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:path?': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'bjsk.org.cn': {
|
||||
_name: '北京社科网',
|
||||
'.': [
|
||||
{
|
||||
title: '通用',
|
||||
docs: 'https://docs.rsshub.app/government.html#bei-jing-she-ke-wang',
|
||||
source: ['/*'],
|
||||
target: (_, url) => `/bjsk/${url.split('/')[3].replace('.html', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:path?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user