diff --git a/docs/traditional-media.md b/docs/traditional-media.md index b77d8aa77f..1c138a28ac 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -624,7 +624,15 @@ IT・科学 tech_science ### 上海新闻 - + + +### 热点搜索 + + + +### 原创 + + ## 読売新聞 diff --git a/lib/v2/eastday/find.js b/lib/v2/eastday/find.js new file mode 100644 index 0000000000..cfc21d599a --- /dev/null +++ b/lib/v2/eastday/find.js @@ -0,0 +1,49 @@ +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 rootUrl = 'https://apin.eastday.com'; + const currentUrl = `${rootUrl}/api/news/Find`; + + const response = await got({ + method: 'post', + url: currentUrl, + json: { + currentPage: 1, + newsType: 1, + pageSize: 30, + query: '', + }, + }); + + const list = response.data.newsList.list.map((item) => ({ + link: item.url, + title: item.title, + pubDate: timezone(parseDate(item.time), +8), + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description = content('.detail').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '热点搜索 - 东方网', + link: 'https://news.eastday.com/china/index_K43594.html', + item: items, + }; +}; diff --git a/lib/v2/eastday/maintainer.js b/lib/v2/eastday/maintainer.js new file mode 100644 index 0000000000..faa6d7e167 --- /dev/null +++ b/lib/v2/eastday/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/find': ['nczitzk'], + '/portrait': ['nczitzk'], +}; diff --git a/lib/v2/eastday/portrait.js b/lib/v2/eastday/portrait.js new file mode 100644 index 0000000000..eafc0d6f6c --- /dev/null +++ b/lib/v2/eastday/portrait.js @@ -0,0 +1,47 @@ +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 rootUrl = 'https://apin.eastday.com'; + const currentUrl = `${rootUrl}/api/news/Portrait`; + + const response = await got({ + method: 'post', + url: currentUrl, + json: { + currentPage: 1, + pageSize: 30, + }, + }); + + const list = response.data.list.map((item) => ({ + link: item.url, + title: item.title, + pubDate: timezone(parseDate(item.time), +8), + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description = content('.detail').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '原创 - 东方网', + link: 'https://www.eastday.com/eastday/shouye/07index/yc/index.html', + item: items, + }; +}; diff --git a/lib/v2/eastday/radar.js b/lib/v2/eastday/radar.js new file mode 100644 index 0000000000..a72380b774 --- /dev/null +++ b/lib/v2/eastday/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'eastday.com': { + _name: '东方网', + www: [ + { + title: '热点搜索', + docs: 'https://docs.rsshub.app/traditional-media.html#dong-fang-wang-re-dian-sou-suo', + source: '/', + target: '/eastday/find', + }, + { + title: '原创', + docs: 'https://docs.rsshub.app/traditional-media.html#dong-fang-wang-yuan-chuang', + source: '/', + target: '/eastday/portrait', + }, + ], + }, +}; diff --git a/lib/v2/eastday/router.js b/lib/v2/eastday/router.js new file mode 100644 index 0000000000..84a23f5e11 --- /dev/null +++ b/lib/v2/eastday/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/find', require('./find')); + router.get('/portrait', require('./portrait')); +};