fix(route): hitwh (#14519)

This commit is contained in:
Tony
2024-02-21 22:26:51 +08:00
committed by GitHub
parent 1653540975
commit 88a594eea6
+10 -2
View File
@@ -6,7 +6,11 @@ const timezone = require('@/utils/timezone');
const baseUrl = 'https://today.hitwh.edu.cn';
module.exports = async (ctx) => {
const response = await got(`${baseUrl}/1024/list.htm`);
const response = await got(`${baseUrl}/1024/list.htm`, {
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(response.data);
const type = (filename) => filename.split('.').pop();
const links = $('.list_list_wrap #wp_news_w10002 ul > li')
@@ -25,7 +29,11 @@ module.exports = async (ctx) => {
ctx.cache.tryGet(item.link, async () => {
if (type(item.link) === 'htm') {
try {
const { data } = await got(item.link);
const { data } = await got(item.link, {
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(data);
item.description = $('div.wp_articlecontent').html() && $('div.wp_articlecontent').html().replaceAll('src="/', `src="${baseUrl}/`).replaceAll('href="/', `href="${baseUrl}/`).trim();
return item;