Skip to content

Commit

Permalink
Merge pull request #2260 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Nov 27, 2023
2 parents d6d1023 + 08c88c2 commit c0def92
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2594,7 +2594,7 @@ router.get('/cbndata/information/:category?', lazyloadRouteHandler('./routes/cbn
router.get('/tanchinese/:category?', lazyloadRouteHandler('./routes/tanchinese'));

// Harvard
router.get('/harvard/health/blog', lazyloadRouteHandler('./routes/universities/harvard/health/blog'));
// router.get('/harvard/health/blog', lazyloadRouteHandler('./routes/universities/harvard/health/blog'));

// yuzu emulator
router.get('/yuzu-emu/entry', lazyloadRouteHandler('./routes/yuzu-emu/entry'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const rootUrl = 'https://www.health.harvard.edu';
Expand All @@ -12,17 +13,16 @@ module.exports = async (ctx) => {

const $ = cheerio.load(response.data);

const list = $('.text-2xl')
.slice(0, 10)
.map((_, item) => {
const list = $('.lg\\:text-2xl')
.toArray()
.map((item) => {
item = $(item).parent();

return {
title: item.text(),
link: item.attr('href'),
};
})
.get();
});

const items = await Promise.all(
list.map((item) =>
Expand All @@ -33,10 +33,11 @@ module.exports = async (ctx) => {
});
const content = cheerio.load(detailResponse.data);

const date = item.link.substr(item.link.length - 12, 8);
const ldJson = JSON.parse(content('script[type="application/ld+json"]').text())['@graph'].find((i) => i['@type'] === 'Article');

item.description = content('.content-repository-content').html();
item.pubDate = Date.parse(`${date.substr(0, 4)}-${date.substr(4, 2)}-${date.substr(6, 2)}`);
item.pubDate = parseDate(ldJson.datePublished);
item.author = ldJson.author.name;

return item;
})
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/harvard/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/health/blog': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/harvard/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'harvard.edu': {
_name: 'Harvard University',
'www.health': [
{
title: 'Health Blog',
docs: 'https://docs.rsshub.app/routes/new-media#harvard-health-publishing',
source: ['/blog'],
target: '/harvard/health/blog',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/harvard/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/health/blog', require('./health/blog'));
};
2 changes: 1 addition & 1 deletion website/docs/routes/new-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ Click here to view [All Topics](https://hbr.org/topics)

## Harvard Health Publishing {#harvard-health-publishing}

### Harvard Health Blog {#harvard-health-publishing-harvard-health-blog}
### Health Blog {#harvard-health-publishing-health-blog}

<Route author="nczitzk" example="/harvard/health/blog" path="/harvard/health/blog" />

Expand Down

0 comments on commit c0def92

Please sign in to comment.