feat(route): cpuid (#10290)

* feat(route): cpuid

* fix: add data.link
This commit is contained in:
Tony
2022-07-21 23:01:36 +08:00
committed by GitHub
parent deeec41d0a
commit 72d768ab0b
5 changed files with 58 additions and 0 deletions
+6
View File
@@ -120,6 +120,12 @@ Language
<RouteEn author="ttttmr" example="/clash/premium" path="/clash/premium" radar="1" />
## CPUID
### News
<RouteEn author="TonyRL" example="/cpuid/news" path="/cpuid/news" radar="1" rssbud="1"/>
## CurseForge
### File Update
+6
View File
@@ -146,6 +146,12 @@ pageClass: routes
<Route author="ttttmr" example="/clash/premium" path="/clash/premium" radar="1" />
## CPUID
### 新闻
<Route author="TonyRL" example="/cpuid/news" path="/cpuid/news" radar="1" rssbud="1"/>
## cpython
### 正式版本发布
+30
View File
@@ -0,0 +1,30 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const newsUrl = 'https://www.cpuid.com/news.html';
module.exports = async (ctx) => {
const response = await got(newsUrl);
const $ = cheerio.load(response.data);
const items = $('.block_100 .js-block-news')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('.information a').text(),
description: item.find('.description').html(),
link: item.find('.information a').attr('href'),
pubDate: parseDate(item.find('time[itemprop=dateCreated]').attr('datetime')),
};
});
ctx.state.data = {
title: $('head title').text(),
description: $('head description').attr('content'),
link: newsUrl,
image: $('link[rel=apple-touch-icon-precomposed]').attr('href'),
item: items,
language: $('html').attr('lang'),
};
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'cpuid.com': {
_name: 'CPUID',
'.': [
{
title: 'News',
docs: 'https://docs.rsshub.app/program-update.html#cpuid',
source: ['/news.html', '/'],
target: '/cpuid/news',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/news', require('./news'));
};