forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add route for Engineering blogs (DIYgod#16529)
* 制作imhcg的路由 * 遵循路由规范 * Update lib/routes/imhcg/blog.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/imhcg/blog.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * 修改imhcg的namespace,使其与route name不同 * Update lib/routes/imhcg/namespace.ts ---------
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Route, ViewType } from '@/types'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { load } from 'cheerio'; | ||
|
||
export const route: Route = { | ||
path: '/', | ||
categories: ['blog'], | ||
view: ViewType.Notifications, | ||
example: '/', | ||
parameters: {}, | ||
radar: [ | ||
{ | ||
source: ['infos.imhcg.cn'], | ||
}, | ||
], | ||
name: 'Engineering blogs', | ||
maintainers: ['ZiHao256'], | ||
handler, | ||
url: 'https://infos.imhcg.cn/', | ||
}; | ||
|
||
async function handler() { | ||
const response = await ofetch('https://infos.imhcg.cn/'); | ||
const $ = load(response); | ||
const items = $('li') | ||
.toArray() | ||
.map((item) => { | ||
const title = $(item).find('a.title').text(); | ||
const link = $(item).find('a.title').attr('href'); | ||
const author = $(item).find('p.author').text(); | ||
const time = $(item).find('p.time').text(); | ||
const description = $(item).find('p.text').text(); | ||
return { | ||
title, | ||
link, | ||
author, | ||
time, | ||
description, | ||
}; | ||
}); | ||
|
||
return { | ||
title: `Engineering Blogs`, | ||
link: 'https://infos.imhcg.cn/', | ||
item: items, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'imhcg的信息站', | ||
url: 'infos.imhcg.cn', | ||
description: '包含多种技术和新闻信息的网站', | ||
}; |