diff --git a/docs/README.md b/docs/README.md index 60da692c4..9479e948b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1437,6 +1437,10 @@ GitHub 官方也提供了一些 RSS: 例如会议讲座的路径为`/taxonomy/term/10/25`,则可以通过`/hit/today/25`订阅该详细类别。 ::: +::: warning 注意 +部分文章需要经过统一身份认证后才能阅读全文。 +::: + ### 上海科技大学 diff --git a/lib/routes/universities/hit/today.js b/lib/routes/universities/hit/today.js index 6261acfd8..48b865f16 100644 --- a/lib/routes/universities/hit/today.js +++ b/lib/routes/universities/hit/today.js @@ -15,24 +15,51 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const category_name = $('div.banner-title').text(); - const list = $('.paragraph li span span a') - .map((i, e) => $(e).attr('href')) + const list = $('.paragraph li') + .map((i, e) => ({ + path: $('span span a', e).attr('href'), + title: $('span span a', e).text(), + author: $('div a', e) + .attr('hreflang', 'zh-hans') + .text(), + })) .get(); const out = await Promise.all( list.map(async (item) => { - const link = host + item; + const { path, title, author } = item; + const link = host + path; + const cache = await ctx.cache.get(link); if (cache) { return Promise.resolve(JSON.parse(cache)); } + const response = await axios.get(link); + + if (response.request.res.connection._host === 'ids.hit.edu.cn') { + const single = { + pubDate: new Date( + link + .split('/') + .slice(-4, -1) + .join('-') + ).toUTCString(), + author: author, + link: link, + title: title, + description: '请进行统一身份认证后查看全文', + }; + ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60); + return Promise.resolve(single); + } + const $ = cheerio.load(response.data); const single = { pubDate: new Date($('.left-attr.first').text()).toUTCString(), - author: $('.bottom_misc span span a').text(), + author: author, link: link, - title: $('.article-title h3').text(), + title: title, description: $('.article-content').text(), };