mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-01 09:38:04 +08:00
* 增加大数据专家委员会和中国人工智能学会新闻 * 修复问题 * fix: add docs for `caai` fix: maintainer does not with match with router * fix: add docs for `ccf/tfbd` fix: use raw output for `art-template` fix: standardise use of `got` not using `got()` in one place and `got.get()` in another place * refactor: migrate to v2 ---------
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
const cheerio = require('cheerio');
|
|
const got = require('@/utils/got');
|
|
const { art } = require('@/utils/render');
|
|
const path = require('path');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const timezone = require('@/utils/timezone');
|
|
|
|
const base = 'http://tfbd.ccf.org.cn';
|
|
|
|
const urlBase = (caty, id) => base + `/tfbd/${caty}/${id}/`;
|
|
|
|
const renderDesc = (desc) =>
|
|
art(path.join(__dirname, '../templates/tfbd/description.art'), {
|
|
desc,
|
|
});
|
|
|
|
const detailPage = (e, cache) =>
|
|
cache.tryGet(e.link, async () => {
|
|
const result = await got(e.link);
|
|
const $ = cheerio.load(result.data);
|
|
e.description = $('div.articleCon').html();
|
|
|
|
return e;
|
|
});
|
|
|
|
const fetchAllArticles = (data) => {
|
|
const $ = cheerio.load(data);
|
|
const articles = $('div.file-list div.article-item');
|
|
const info = articles.toArray().map((e) => {
|
|
const c = $(e);
|
|
const r = {
|
|
title: c.find('h3 a[href]').text().trim(),
|
|
link: base + c.find('h3 a[href]').attr('href'),
|
|
pubDate: timezone(parseDate(c.find('p').text().trim(), 'YYYY-MM-DD'), +8),
|
|
};
|
|
return r;
|
|
});
|
|
return info;
|
|
};
|
|
|
|
module.exports = {
|
|
BASE: base,
|
|
urlBase,
|
|
fetchAllArticles,
|
|
detailPage,
|
|
renderDesc,
|
|
};
|