Skip to content

Commit

Permalink
feat(route): recover route blogread/newest (DIYgod#14937)
Browse files Browse the repository at this point in the history
* feat(route): recover route blogread/newest

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

* Update lib/routes/blogread/index.ts

---------
  • Loading branch information
fashioncj authored Mar 24, 2024
1 parent d22a63c commit 7ac4ffd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
3 changes: 0 additions & 3 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 changes: 6 additions & 0 deletions lib/routes/blogread/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '技术头条',
url: 'blogread.cn',
};

0 comments on commit 7ac4ffd

Please sign in to comment.