mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-13 00:35:19 +08:00
* 添加"哈尔滨工业大学研究生院通知公告"路由 * 修改路由为v2 script * chore(deps): bump puppeteer from 17.1.2 to 17.1.3 (#1094) Bumps [puppeteer](https://github.com/puppeteer/puppeteer) from 17.1.2 to 17.1.3. - [Release notes](https://github.com/puppeteer/puppeteer/releases) - [Changelog](https://github.com/puppeteer/puppeteer/blob/main/CHANGELOG.md) - [Commits](https://github.com/puppeteer/puppeteer/compare/v17.1.2...v17.1.3) --- updated-dependencies: - dependency-name: puppeteer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update lib/v2/hit/hitgs.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * change code style of hitgs.js * add radar.js * change http to https for older HIT files * refactor: migrate to v2 * docs: fix format * fix: code scan Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
60 lines
2.1 KiB
JavaScript
60 lines
2.1 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const timezone = require('@/utils/timezone');
|
|
|
|
module.exports = async (ctx) => {
|
|
const host = 'https://today.hit.edu.cn';
|
|
const category = ctx.params.category;
|
|
|
|
const response = await got(host + '/category/' + category, {
|
|
headers: {
|
|
Referer: host,
|
|
},
|
|
});
|
|
|
|
const $ = cheerio.load(response.data);
|
|
const list = $('.paragraph li')
|
|
.toArray()
|
|
.map((e) => ({
|
|
link: new URL($('span span a', e).attr('href'), host).href,
|
|
title: $('span span a', e).text(),
|
|
author: $('div a', e).attr('hreflang', 'zh-hans').text(),
|
|
pubDate: timezone(parseDate($('span span a', e).attr('href').split('/').slice(-4, -1).join(), 'YYYYMMDD'), 8),
|
|
}));
|
|
|
|
const out = await Promise.all(
|
|
list.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
try {
|
|
const response = await got(item.link, {
|
|
headers: {
|
|
Referer: host,
|
|
},
|
|
});
|
|
|
|
const $ = cheerio.load(response.data);
|
|
item.pubDate = timezone(parseDate($('.left-attr.first').text().trim()), 8);
|
|
item.description =
|
|
$('.article-content').html() &&
|
|
$('.article-content')
|
|
.html()
|
|
.replace(/src="\//g, `src="${new URL('.', host).href}`)
|
|
.replace(/href="\//g, `href="${new URL('.', host).href}`)
|
|
.trim();
|
|
} catch (e) {
|
|
// intranet
|
|
item.description = '请进行统一身份认证后查看全文';
|
|
}
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: $('head title').text().trim(),
|
|
link: host + '/category/' + category,
|
|
item: out,
|
|
};
|
|
};
|