Skip to content

Commit

Permalink
fix(route): hitwh (DIYgod#14519)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Feb 21, 2024
1 parent 1653540 commit 88a594e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/v2/hitwh/today.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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;
Expand Down

0 comments on commit 88a594e

Please sign in to comment.