feat(route): recover route blogread/newest (#14937)

* feat(route): recover route blogread/newest

* fix(route): Update lib/routes/blogread/index.ts

* Update lib/routes/blogread/index.ts

---------
This commit is contained in:
Jia Chen
2024-03-25 00:27:11 +08:00
committed by GitHub
parent d22a63c6d0
commit 7ac4ffd1ae
3 changed files with 28 additions and 10 deletions
-3
View File
@@ -379,9 +379,6 @@ router.get('/geekpark/breakingnews', lazyloadRouteHandler('./routes/geekpark/bre
// 香港天文台
router.get('/hko/weather', lazyloadRouteHandler('./routes/hko/weather'));
// 技术头条
router.get('/blogread/newest', lazyloadRouteHandler('./routes/blogread/newest'));
// gnn游戏新闻
router.get('/gnn/gnn', lazyloadRouteHandler('./routes/gnn/gnn'));
@@ -1,8 +1,23 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
import { Route } from '@/types';
import got from '@/utils/got';
import * as cheerio from 'cheerio';
module.exports = async (ctx) => {
const url = 'http://blogread.cn/news/newest.php';
export const route: Route = {
path: '/newest',
categories: ['programming'],
example: '/blogread/newest',
radar: [
{
source: ['blogread.cn/news/newest.php'],
},
],
name: '最新文章',
maintainers: ['fashioncj'],
handler,
};
async function handler() {
const url = 'https://blogread.cn/news/newest.php';
const response = await got({
method: 'get',
url,
@@ -12,19 +27,19 @@ module.exports = async (ctx) => {
.map((index, elem) => {
elem = $(elem);
const $link = elem.find('dt a');
return {
title: $link.text(),
description: elem.find('dd').eq(0).text(),
link: $link.attr('href'),
author: elem.find('.small a').eq(0).text(),
pubDate: elem.find('dd').eq(1).text().split('\n')[2],
};
})
.get();
ctx.state.data = {
return {
title: '技术头条',
link: url,
item: resultItem,
};
};
}
+6
View File
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '技术头条',
url: 'blogread.cn',
};