mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
@@ -162,6 +162,12 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="kt286" example="/bof/home" path="/bof/home" />
|
<Route author="kt286" example="/bof/home" path="/bof/home" />
|
||||||
|
|
||||||
|
## C114 通信网
|
||||||
|
|
||||||
|
### 滚动新闻
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/c114/roll" path="/c114/roll"/>
|
||||||
|
|
||||||
## CBNData
|
## CBNData
|
||||||
|
|
||||||
### 看点
|
### 看点
|
||||||
|
|||||||
3
lib/v2/c114/maintainer.js
Normal file
3
lib/v2/c114/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/roll': ['nczitzk'],
|
||||||
|
};
|
||||||
13
lib/v2/c114/radar.js
Normal file
13
lib/v2/c114/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'c114.com.cn': {
|
||||||
|
_name: 'C114通信网',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '滚动新闻',
|
||||||
|
docs: 'https://docs.rsshub.app/new-media.html#c114-tong-xin-wang-gun-dong-xin-wen',
|
||||||
|
source: ['/news/roll.asp', '/'],
|
||||||
|
target: '/c114/roll',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
57
lib/v2/c114/roll.js
Normal file
57
lib/v2/c114/roll.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const iconv = require('iconv-lite');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const rootUrl = 'https://www.c114.com.cn';
|
||||||
|
const currentUrl = `${rootUrl}/news/roll.asp`;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: currentUrl,
|
||||||
|
responseType: 'buffer',
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||||
|
|
||||||
|
let items = $('.new_list_c h6 a')
|
||||||
|
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 50)
|
||||||
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
|
item = $(item);
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: item.text(),
|
||||||
|
link: item.attr('href'),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
items = await Promise.all(
|
||||||
|
items.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
responseType: 'buffer',
|
||||||
|
});
|
||||||
|
|
||||||
|
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||||
|
|
||||||
|
item.description = content('.text').html();
|
||||||
|
item.author = content('.author').first().text().replace('C114通信网 ', '');
|
||||||
|
item.pubDate = timezone(parseDate(content('.r_time').text()), +8);
|
||||||
|
item.category = content('meta[name="keywords"]').attr('content').split(',');
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title').text(),
|
||||||
|
link: currentUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/c114/router.js
Normal file
3
lib/v2/c114/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/roll', require('./roll'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user