Files
RSSHub/lib/routes/cnki/utils.ts
T
Derek 6cdaa3f2af fix(cnki): deprecate author articles with :code, now use :name and :company instead (#17682)
* router: fix author

* format

* Update lib/routes/cnki/author.ts

* update

---------
2024-11-22 23:03:46 -08:00

28 lines
806 B
TypeScript

import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
import path from 'node:path';
const ProcessItem = async (item) => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
item.description = art(path.join(__dirname, 'templates/desc.art'), {
author: $('h3.author > span')
.toArray()
.map((item) => $(item).text())
.join(' '),
company: $('a.author')
.toArray()
.map((item) => $(item).text())
.join(' '),
content: $('div.row > span.abstract-text').parent().text(),
});
return item;
};
export { ProcessItem };