mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat: add 10000link news fulltext (#2681)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -928,6 +928,17 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 万联网
|
||||||
|
|
||||||
|
### 资讯
|
||||||
|
|
||||||
|
<Route author="kt286" example="/10000link/news/My01" path="/10000link/news/:category?" :paramsDesc="['栏目代码, 默认为全部']">
|
||||||
|
|
||||||
|
| 全部 | 天下大势 | 企业动态 | 专家观点 | 研究报告 |
|
||||||
|
| ---- | -------- | -------- | -------- | -------- |
|
||||||
|
| (空) | My01 | My02 | My03 | My04 |
|
||||||
|
|
||||||
|
</Route>
|
||||||
## 维基百科
|
## 维基百科
|
||||||
|
|
||||||
### 中国大陆新闻动态
|
### 中国大陆新闻动态
|
||||||
|
|||||||
@@ -1556,6 +1556,9 @@ router.get('/wikihow/category/:category/:type', require('./routes/wikihow/catego
|
|||||||
router.get('/getitfree/category/:category?', require('./routes/getitfree/category.js'));
|
router.get('/getitfree/category/:category?', require('./routes/getitfree/category.js'));
|
||||||
router.get('/getitfree/search/:keyword?', require('./routes/getitfree/search.js'));
|
router.get('/getitfree/search/:keyword?', require('./routes/getitfree/search.js'));
|
||||||
|
|
||||||
|
// 万联网
|
||||||
|
router.get('/10000link/news/:category?', require('./routes/10000link/news'));
|
||||||
|
|
||||||
// Artand
|
// Artand
|
||||||
router.get('/artand/user/work/:uid', require('./routes/artand/user/work'));
|
router.get('/artand/user/work/:uid', require('./routes/artand/user/work'));
|
||||||
|
|
||||||
|
|||||||
64
lib/routes/10000link/news.js
Normal file
64
lib/routes/10000link/news.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
const { addNoReferrer } = require('@/utils/common-utils');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const category = ctx.params.category;
|
||||||
|
const pageUrl = `http://info.10000link.com/newslists.aspx?chid=${category}`;
|
||||||
|
const host = 'http://info.10000link.com';
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: pageUrl,
|
||||||
|
});
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const list = $('.l_newshot li').get();
|
||||||
|
|
||||||
|
const ProcessFeed = async (link) => {
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
addNoReferrer($, '#news_body');
|
||||||
|
|
||||||
|
return $('#news_body').html();
|
||||||
|
};
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const $ = cheerio.load(item);
|
||||||
|
const $a = $('h1 a');
|
||||||
|
const link = url.resolve(host, $a.attr('href'));
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const description = await ProcessFeed(link);
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: $a.text(),
|
||||||
|
description,
|
||||||
|
link: link,
|
||||||
|
pubDate: new Date($('.ymd_w').text()).toUTCString(),
|
||||||
|
author: $('.day-lx span:first-child').text(),
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.cache.set(link, JSON.stringify(single));
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `万联网 ${$('.t-h2')
|
||||||
|
.text()
|
||||||
|
.replace(' |资讯频道', '')}`,
|
||||||
|
link: pageUrl,
|
||||||
|
description: $('meta[name="Description"]').attr('content'),
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user