diff --git a/docs/en/new-media.md b/docs/en/new-media.md index 96a60f2a21..e6a1f175a4 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -63,11 +63,11 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more ### Channel - + -| Home | Research | Industry | Financing | Politics | Celebrity | Company | Product | Activity | -| ---- | -------- | -------- | --------- | -------- | --------- | ------- | ------- | -------- | -| home | research | industry | financing | politics | celebrity | company | product | activity | +| Research | Interview | Industry | Activity | +| -------- | --------- | -------- | -------- | +| reaseach | interview | industry | activity | diff --git a/docs/new-media.md b/docs/new-media.md index 70ac745812..5c7e2498d2 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2106,11 +2106,11 @@ column 为 third 时可选的 category: ### 频道 - + -| 首页 | 研究 | 产业 | 融资 | 时政 | 人物 | 公司 | 新品 | 活动 | -| ---- | -------- | -------- | --------- | -------- | --------- | ------- | ------- | -------- | -| home | research | industry | financing | politics | celebrity | company | product | activity | +| 最新研究 | 人物访谈 | 产业动态 | 活动发布 | +| -------- | --------- | -------- | -------- | +| reaseach | interview | industry | activity | diff --git a/lib/router.js b/lib/router.js index ecf74d4d43..e56cf69896 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4203,9 +4203,6 @@ router.get('/x410/news', lazyloadRouteHandler('./routes/x410/news')); // 恩山无线论坛 router.get('/right/forum/:id?', lazyloadRouteHandler('./routes/right/forum')); -// 生物探索 -router.get('/biodiscover/:channel?', lazyloadRouteHandler('./routes/biodiscover')); - // 香港經濟日報 router.get('/hket/:category?', lazyloadRouteHandler('./routes/hket/index')); diff --git a/lib/routes/biodiscover/index.js b/lib/routes/biodiscover/index.js deleted file mode 100644 index 4ee285bdb7..0000000000 --- a/lib/routes/biodiscover/index.js +++ /dev/null @@ -1,43 +0,0 @@ -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((itemUrl) => - 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, - }; - }) - ) - ), - }; -}; diff --git a/lib/v2/biodiscover/index.js b/lib/v2/biodiscover/index.js new file mode 100644 index 0000000000..5369c364e9 --- /dev/null +++ b/lib/v2/biodiscover/index.js @@ -0,0 +1,44 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const channel = ctx.params.channel; + const listUrl = 'http://www.biodiscover.com/' + channel; + const response = await got({ url: listUrl }); + const $ = cheerio.load(response.data); + + const items = $('.new_list .newList_box') + .map((_, item) => ({ + pubDate: parseDate($(item).find('.news_flow_tag .times').text().trim()), + link: 'http://www.biodiscover.com' + $(item).find('h2 a').attr('href'), + })) + .toArray(); + + ctx.state.data = { + title: '生物探索 - ' + $('.header li.sel a').text(), + link: listUrl, + description: $('meta[name=description]').attr('content'), + item: await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ url: item.link }); + const $ = cheerio.load(detailResponse.data); + + // remove sharing info if exists + const lastNode = $('.main_info').children().last(); + if (lastNode.css('display') === 'none') { + lastNode.remove(); + } + + return { + title: $('h1').text().trim(), + description: $('.main_info').html(), + pubDate: item.pubDate, + link: item.link, + }; + }) + ) + ), + }; +}; diff --git a/lib/v2/biodiscover/maintainer.js b/lib/v2/biodiscover/maintainer.js new file mode 100644 index 0000000000..021f23c705 --- /dev/null +++ b/lib/v2/biodiscover/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:channel?': ['aidistan'], +}; diff --git a/lib/v2/biodiscover/radar.js b/lib/v2/biodiscover/radar.js new file mode 100644 index 0000000000..62017094bf --- /dev/null +++ b/lib/v2/biodiscover/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'biodiscover.com': { + _name: '生物探索', + www: [ + { + title: '频道', + docs: 'https://docs.rsshub.app/new-media.html#sheng-wu-tan-suo', + source: '/:channel', + target: '/biodiscover/:channel', + }, + ], + }, +}; diff --git a/lib/v2/biodiscover/router.js b/lib/v2/biodiscover/router.js new file mode 100644 index 0000000000..91b8719d66 --- /dev/null +++ b/lib/v2/biodiscover/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:channel?', require('./index')); +};