* 南京艺术学院研究生院 * Update lib/v2/nua/gra.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/nua/gra.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/nua/gra.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/nua/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/nua/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/nua/gra.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/nua/gra.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/university.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/university.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * 优化代码 * 优化 * update * 补充南京艺术学院 * fix * fix * fix * 更新南京艺术学院数据源。 * 更新南京艺术学院数据源。 * fix * fix * update * fix doc * fix * Update lib/v2/nua/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix: yarn.lock permission * style: auto format * fix double fetch same page * Update dc.js * Revert "Merge branch 'master' of https://github.com/evnydd0sf/RSS-Hub" This reverts commit dd56f9469b5b2462d482c202ae798b3f159f243e, reversing changes made to d900050eb8271d0f566070eb58c2c9d87ccd6e53. * fix * Revert "fix" This reverts commit 820ff88120d4fb4fc2bdcd8ee52229d1bfb83c17. * Revert "Revert "Merge branch 'master' of https://github.com/evnydd0sf/RSS-Hub"" This reverts commit ce67e0b53c231a8a8527b7407211aff1ab7e50d4. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const timezone = require('@/utils/timezone');
|
|
|
|
async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) {
|
|
const result = await got(newsUrl, {
|
|
https: {
|
|
rejectUnauthorized: false,
|
|
},
|
|
});
|
|
const $ = cheerio.load(result.data);
|
|
|
|
const pageName = $(webPageName).text();
|
|
|
|
let artiLink;
|
|
|
|
const items = $(listName)
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
if (item.find('a').attr('href').includes('http')) {
|
|
artiLink = item.find('a').attr('href');
|
|
} else {
|
|
artiLink = baseUrl + item.find('a').attr('href');
|
|
}
|
|
|
|
return {
|
|
link: artiLink,
|
|
title: item.find('a').attr('title'),
|
|
pubDate: timezone(parseDate(item.find(listDate).first().text(), 'YYYY-MM-DD'), +8),
|
|
};
|
|
});
|
|
|
|
return [items, pageName];
|
|
}
|
|
|
|
const ProcessFeed = async (items, artiContent, cache) =>
|
|
await Promise.all(
|
|
items.map((item) =>
|
|
cache.tryGet(item.link, async () => {
|
|
const result = await got(item.link, {
|
|
https: {
|
|
rejectUnauthorized: false,
|
|
},
|
|
});
|
|
const $ = cheerio.load(result.data);
|
|
|
|
item.author = $('.arti_publisher').text() + ' ' + $('.arti_views').text();
|
|
item.description = $(artiContent).html();
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
module.exports = {
|
|
ProcessList,
|
|
ProcessFeed,
|
|
};
|