RSSHub/lib/routes/caai/index.ts

43 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Route } from '@/types';
import cache from '@/utils/cache';
import utils from './utils';
import got from '@/utils/got';
import { load } from 'cheerio';
export const route: Route = {
path: '/:caty',
categories: ['study'],
example: '/caai/45',
parameters: { caty: '分类 ID可在 URL 找到' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '学会动态',
maintainers: ['tudou027'],
handler,
};
async function handler(ctx) {
const base = utils.urlBase(ctx.req.param('caty'));
const res = await got(base);
const info = utils.fetchAllArticles(res.data);
const $ = load(res.data);
const details = await Promise.all(info.map((e) => utils.detailPage(e, cache)));
ctx.set('json', {
info,
});
return {
title: '中国人工智能学会 - ' + $('.article-list h1').text(),
link: base,
item: details,
};
}