mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
@@ -4114,6 +4114,35 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/
|
||||
|
||||
<Route author="nczitzk" example="/cria/news/1" path="/cria/news/:id?" :paramsDesc="['列表 id,可在列表页的 URL 中找到,默认为首页']"/>
|
||||
|
||||
## 重构
|
||||
|
||||
### 推荐
|
||||
|
||||
<Route author="nczitzk" example="/allrecode/recommends" path="/allrecode/recommends" />
|
||||
|
||||
### 快讯
|
||||
|
||||
<Route author="nczitzk" example="/allrecode/news" path="/allrecode/news" />
|
||||
|
||||
### 资讯
|
||||
|
||||
<Route author="nczitzk" example="/allrecode/posts" path="/allrecode/:category?" :paramsDesc="['分类,见下表,默认为全部']">
|
||||
|
||||
| 分类 | id |
|
||||
| ---- | ------------------ |
|
||||
| 全部 | posts |
|
||||
| NFT | non-fungible-token |
|
||||
| DAO | dao |
|
||||
| Web3 | web3 |
|
||||
| 安全 | security |
|
||||
| 政策 | global-policy |
|
||||
| 元宇宙 | metaverse |
|
||||
| 区块链 | blockchain |
|
||||
| 融资新闻 | financing-news |
|
||||
| 趋势观察 | trend-observation |
|
||||
|
||||
</Route>
|
||||
|
||||
## 眾新聞
|
||||
|
||||
### 眾聞
|
||||
|
||||
65
lib/v2/allrecode/index.js
Normal file
65
lib/v2/allrecode/index.js
Normal file
@@ -0,0 +1,65 @@
|
||||
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 ?? 'posts';
|
||||
|
||||
const rootUrl = 'https://allrecode.com';
|
||||
const currentUrl = `${rootUrl}/${category}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('h3 a')
|
||||
.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,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.author = content('.author').text();
|
||||
item.category = content('meta[name="keywords"]').attr('content').split(',');
|
||||
item.pubDate = timezone(
|
||||
parseDate(
|
||||
content('.edit')
|
||||
.text()
|
||||
.match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}/)
|
||||
),
|
||||
+8
|
||||
);
|
||||
|
||||
content('.edit, .shang').remove();
|
||||
|
||||
item.description = content('.article-content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
5
lib/v2/allrecode/maintainer.js
Normal file
5
lib/v2/allrecode/maintainer.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
'/news': ['nczitzk'],
|
||||
'/recommends': ['nczitzk'],
|
||||
'/:category?': ['nczitzk'],
|
||||
};
|
||||
35
lib/v2/allrecode/news.js
Normal file
35
lib/v2/allrecode/news.js
Normal file
@@ -0,0 +1,35 @@
|
||||
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 rootUrl = 'https://allrecode.com';
|
||||
const currentUrl = `${rootUrl}/news`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const items = $('.news-trigger')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
pubDate: timezone(parseDate(item.parent().prev().text(), 'HH:mm'), +8),
|
||||
description: item.parent().next().html(),
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
25
lib/v2/allrecode/radar.js
Normal file
25
lib/v2/allrecode/radar.js
Normal file
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
'allrecode.com': {
|
||||
_name: '重构',
|
||||
'.': [
|
||||
{
|
||||
title: '推荐',
|
||||
docs: 'https://docs.rsshub.app/news-media.html#chong-gou-tui-jian',
|
||||
source: ['/recommends', '/'],
|
||||
target: '/allrecode/recommends',
|
||||
},
|
||||
{
|
||||
title: '快讯',
|
||||
docs: 'https://docs.rsshub.app/news-media.html#chong-gou-kuai-xun',
|
||||
source: ['/news', '/'],
|
||||
target: '/allrecode/news',
|
||||
},
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/news-media.html#chong-gou-zi-xun',
|
||||
source: ['/:category', '/'],
|
||||
target: '/allrecode/:category',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
4
lib/v2/allrecode/router.js
Normal file
4
lib/v2/allrecode/router.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/news', require('./news'));
|
||||
router.get('/:category?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user