diff --git a/docs/en/new-media.md b/docs/en/new-media.md index c72e3908b8c611..2697921f520d0c 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -59,6 +59,18 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more +## biodiscover.com + +### Channel + + + +| Home | Research | Industry | Financing | Politics | Celebrity | Company | Product | Activity | +| ---- | -------- | -------- | --------- | -------- | --------- | ------- | ------- | -------- | +| home | research | industry | financing | politics | celebrity | company | product | activity | + + + ## BOF ### Home diff --git a/docs/new-media.md b/docs/new-media.md index 17b6aafbd59fba..69c10eb932fc0a 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1938,6 +1938,18 @@ column 为 third 时可选的 category: +## 生物探索 + +### 频道 + + + +| 首页 | 研究 | 产业 | 融资 | 时政 | 人物 | 公司 | 新品 | 活动 | +| ---- | -------- | -------- | --------- | -------- | --------- | ------- | ------- | -------- | +| home | research | industry | financing | politics | celebrity | company | product | activity | + + + ## 世界卫生组织 WHO ### 媒体中心 diff --git a/lib/router.js b/lib/router.js index ad4925389cdd4d..d0c8423d36091c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4154,4 +4154,7 @@ router.get('/tanchinese/:category?', require('./routes/tanchinese')); // Harvard router.get('/harvard/health/blog', require('./routes/universities/harvard/health/blog')); +// 生物探索 +router.get('/biodiscover/:channel?', require('./routes/biodiscover')); + module.exports = router; diff --git a/lib/routes/biodiscover/index.js b/lib/routes/biodiscover/index.js new file mode 100644 index 00000000000000..ca89a49ab0bed1 --- /dev/null +++ b/lib/routes/biodiscover/index.js @@ -0,0 +1,44 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseRelativeDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const channel = ctx.params.channel || 'home'; + const listUrl = 'http://www.biodiscover.com' + (channel === 'home' ? '/' : '/news/' + channel); + const response = await got({ url: listUrl }); + const $ = cheerio.load(response.data); + + const listTitle = $('.list-title').text().trim(); + const itemUrls = $('.news_list li h2 a') + .map((_, item) => 'http://www.biodiscover.com' + $(item).attr('href')) + .toArray(); + + ctx.state.data = { + title: '生物探索' + (listTitle ? ` - ${listTitle}` : ''), + link: listUrl, + description: $('meta[name=description]').attr('content'), + item: await Promise.all( + itemUrls.map( + async (itemUrl) => + await ctx.cache.tryGet(itemUrl, async () => { + const detailResponse = await got({ url: itemUrl }); + const $ = cheerio.load(detailResponse.data); + + const dateStr = $('.from').children().last().text().replace('·', '').trim(); + + return { + title: $('.article_title').text(), + author: $('.from').children().first().text().trim(), + category: $('.article .share .tag a') + .map((_, a) => $(a).text().trim()) + .toArray(), + description: $('.article .main_info').html(), + pubDate: timezone(parseRelativeDate(dateStr) || new Date(dateStr), +8), + link: itemUrl, + }; + }) + ) + ), + }; +};