diff --git a/lib/routes/imhcg/blog.ts b/lib/routes/imhcg/blog.ts new file mode 100644 index 000000000..a45fdd96c --- /dev/null +++ b/lib/routes/imhcg/blog.ts @@ -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, + }; +} diff --git a/lib/routes/imhcg/namespace.ts b/lib/routes/imhcg/namespace.ts new file mode 100644 index 000000000..33726f676 --- /dev/null +++ b/lib/routes/imhcg/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'imhcg的信息站', + url: 'infos.imhcg.cn', + description: '包含多种技术和新闻信息的网站', +};