diff --git a/assets/radar-rules.js b/assets/radar-rules.js index cde8e7893..11eb680b3 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -256,7 +256,7 @@ }, 'govopendata.com': { _name: '新闻联播文字版', cn: [{ title: '新闻联播文字版', docs: 'https://docs.rsshub.app/traditional-media.html#xin-wen-lian-bo-wen-zi-ban', source: '/xinwenlianbo', target: '/xinwenlianbo/index' }] }, 'steampowered.com': { _name: 'Steam', store: [{ title: 'search', docs: 'https://docs.rsshub.app/game.html#steam', source: '/search/', target: (params, url) => `/steam/search/${new URL(url).searchParams}` }] }, - 'baijingapp.com': { _name: '白鲸出海', www: [{ title: '文章', docs: 'https://docs.rsshub.app/new-media.html#bai-jing-chu-hai', source: '', target: '/baijing' }] }, + // 'baijingapp.com': { _name: '白鲸出海', www: [{ title: '文章', docs: 'https://docs.rsshub.app/new-media.html#bai-jing-chu-hai', source: '', target: '/baijing' }] }, 'xiaomi.cn': { _name: '小米社区', www: [{ title: '圈子', docs: 'https://docs.rsshub.app/bbs.html#xiao-mi-she-qu', source: '/board/:boardId', target: '/mi/bbs/board/:boardId' }] }, '163.com': { _name: '网易', diff --git a/docs/new-media.md b/docs/new-media.md index bf7debf1a..b159798b6 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1444,9 +1444,19 @@ Supported sub-sites: ## 白鲸出海 -### 首页最新帖子 +### 最新 - + + +### 资讯 + + + +| 最新文章 | 7×24h | 干货 | 专栏 | 手游 | 跨境电商 | 投融资 | 数据报告 | 智能手机 | 活动 | +| ---- | ----- | -- | -- | -- | ---- | --- | ---- | ---- | -- | +| | 1 | 2 | 4 | 3 | 5 | 10 | 9 | 7 | 6 | + + ## 百度知道日报 diff --git a/lib/radar-rules.js b/lib/radar-rules.js index 2a8b3abf6..6fc233d03 100644 --- a/lib/radar-rules.js +++ b/lib/radar-rules.js @@ -584,17 +584,17 @@ module.exports = { }, ], }, - 'baijingapp.com': { - _name: '白鲸出海', - www: [ - { - title: '文章', - docs: 'https://docs.rsshub.app/new-media.html#bai-jing-chu-hai', - source: '', - target: '/baijing', - }, - ], - }, + // 'baijingapp.com': { + // _name: '白鲸出海', + // www: [ + // { + // title: '文章', + // docs: 'https://docs.rsshub.app/new-media.html#bai-jing-chu-hai', + // source: '', + // target: '/baijing', + // }, + // ], + // }, 'xiaomi.cn': { _name: '小米社区', www: [ diff --git a/lib/router.js b/lib/router.js index 06cb7ac74..69d77378d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2327,7 +2327,7 @@ router.get('/yahoo-jp-tv/:query', lazyloadRouteHandler('./routes/yahoo-jp-tv/ind router.get('/yahoo-author/:author', lazyloadRouteHandler('./routes/yahoo-author/index')); // 白鲸出海 -router.get('/baijing', lazyloadRouteHandler('./routes/baijing')); +// router.get('/baijing', lazyloadRouteHandler('./routes/baijing')); // 低端影视 router.get('/ddrk/update/:name/:season?', lazyloadRouteHandler('./routes/ddrk/index')); diff --git a/lib/routes/baijing/index.js b/lib/routes/baijing/index.js deleted file mode 100644 index 313ac611c..000000000 --- a/lib/routes/baijing/index.js +++ /dev/null @@ -1,34 +0,0 @@ -const got = require('@/utils/got'); -const date = require('@/utils/date'); - -module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: 'http://www.baijingapp.com/api/get_more_articles/', - }); - - const data = JSON.parse(response.data.substr(1, response.data.length - 1)); - - const output = data.data.list.map((item) => { - const title = item.title; - const link = 'https://www.baijingapp.com/article/' + item.id; - const pubDate = date(item.time.replace(' ', '')); - const author = item.user_name; - const description = ``; - const single = { - title, - link, - pubDate, - author, - description, - }; - - return single; - }); - - ctx.state.data = { - title: `白鲸出海`, - desription: '白鲸出海 - 泛互联网出海服务平台', - item: output, - }; -}; diff --git a/lib/v2/baijing/index.js b/lib/v2/baijing/index.js new file mode 100644 index 000000000..bc55736e2 --- /dev/null +++ b/lib/v2/baijing/index.js @@ -0,0 +1,54 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const type = ctx.params.type ?? ''; + + const rootUrl = 'https://www.baijingapp.com'; + const currentUrl = `${rootUrl}/article${type ? `/type-${type}` : ''}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.article') + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: `${rootUrl}${item.attr('href')}`, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.author = content('.name').text(); + item.description = content('#message').html(); + item.pubDate = timezone(parseDate(content('.timeago').text()), +8); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `白鲸出海 - ${$('.list .active').text()}`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/baijing/maintainer.js b/lib/v2/baijing/maintainer.js new file mode 100644 index 000000000..8874f3c2c --- /dev/null +++ b/lib/v2/baijing/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:type?': ['nczitzk'], +}; diff --git a/lib/v2/baijing/radar.js b/lib/v2/baijing/radar.js new file mode 100644 index 000000000..995ebc6c4 --- /dev/null +++ b/lib/v2/baijing/radar.js @@ -0,0 +1,22 @@ +module.exports = { + 'baijingapp.com': { + _name: '白鲸出海', + '.': [ + { + title: '最新', + docs: 'https://docs.rsshub.app/new-media.html#bai-jing-chu-hai', + source: ['/article', '/'], + target: '/baijing', + }, + { + title: '资讯', + docs: 'https://docs.rsshub.app/new-media.html#bai-jing-chu-hai', + source: ['/article', '/'], + target: (params, url) => { + const matches = String(new URL(url)).match(/\/article\/type-(\d+)/); + return `/baijing${matches ? `/${matches[1]}` : ''}`; + }, + }, + ], + }, +}; diff --git a/lib/v2/baijing/router.js b/lib/v2/baijing/router.js new file mode 100644 index 000000000..7ec1cc98e --- /dev/null +++ b/lib/v2/baijing/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:type?', require('./index')); +};