diff --git a/docs/en/traditional-media.md b/docs/en/traditional-media.md index 4eb7e1ef3..a304f7a8f 100644 --- a/docs/en/traditional-media.md +++ b/docs/en/traditional-media.md @@ -502,6 +502,20 @@ Provides all of the articles by the specified Yahoo! author. +## Yomiuri Shimbun 読売新聞 + +### News + + + +Free articles only. + +| 新着・速報 |   社会 | 政治 | 経済 | スポーツ | 国際 | 科学・IT | 選挙・世論調査 | エンタメ・文化 | 囲碁・将棋 | ライフ | 地域 | 社説 | 皇室 | +| ------- | -------- | -------- | ------- | ------ | ----- | ------- | -------- | ------- | --------- | ---- | ----- | --------- | --------- | +|  news   | national | politics | economy | sports | world | science | election | culture | igoshougi | life | local | editorial | koushitsu | + + + ## 公視新聞網 ### Daily News diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 9ad98eca0..1060097de 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -722,9 +722,9 @@ IT・科学 tech_science 无料全文,综合页 (新着・速報) 文章标题补充板块标签。 -| 新着・速報 |   社会 | 政治 | 経済 | スポーツ | 国際 | 科学・IT | 選挙・世論調査 | エンタメ・文化 | 囲碁・将棋 | ライフ | 地域 | 社説 | -| ------- | -------- | -------- | ------- | ------ | ----- | ------- | -------- | ------- | --------- | ---- | ----- | --------- | -|  news   | national | politics | economy | sports | world | science | election | culture | igoshougi | life | local | editorial | +| 新着・速報 |   社会 | 政治 | 経済 | スポーツ | 国際 | 科学・IT | 選挙・世論調査 | エンタメ・文化 | 囲碁・将棋 | ライフ | 地域 | 社説 | 皇室 | +| ------- | -------- | -------- | ------- | ------ | ----- | ------- | -------- | ------- | --------- | ---- | ----- | --------- | --------- | +|  news   | national | politics | economy | sports | world | science | election | culture | igoshougi | life | local | editorial | koushitsu | diff --git a/lib/router.js b/lib/router.js index a95263f33..52cc36dd7 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3280,8 +3280,8 @@ router.get('/nobelprize/:caty?', lazyloadRouteHandler('./routes/nobelprize/index // 中華民國國防部 router.get('/gov/taiwan/mnd', lazyloadRouteHandler('./routes/gov/taiwan/mnd')); -// 読売新聞 -router.get('/yomiuri/:category', lazyloadRouteHandler('./routes/yomiuri/news')); +// 読売新聞 to v2 +// router.get('/yomiuri/:category', lazyloadRouteHandler('./routes/yomiuri/news')); // 巴哈姆特 // GNN新闻 migrated to v2 diff --git a/lib/v2/yomiuri/maintainer.js b/lib/v2/yomiuri/maintainer.js new file mode 100644 index 000000000..219f20c4d --- /dev/null +++ b/lib/v2/yomiuri/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/yomiuri/:category?': ['Arracc'], +}; diff --git a/lib/routes/yomiuri/news.js b/lib/v2/yomiuri/news.js similarity index 78% rename from lib/routes/yomiuri/news.js rename to lib/v2/yomiuri/news.js index 75d23a7c4..f5c5bb586 100644 --- a/lib/routes/yomiuri/news.js +++ b/lib/v2/yomiuri/news.js @@ -1,6 +1,7 @@ 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 category = ctx.params.category; @@ -17,26 +18,8 @@ module.exports = async (ctx) => { let list = null; if (category === 'news') { categoryName = '新着・速報'; - const urlPrefix = 'https://www.yomiuri.co.jp/y_ajax/'; - // get list1 - const param1 = $('input#latest_list_news_other_params').val(); - const response1 = await got({ - method: 'get', - url: urlPrefix + 'latest_list_news/' + param1 + '/?action=latest_list_news&others=' + param1, - }); - const data1 = response1.data; - const firstArticleList = cheerio.load(data1); - - // get list2 - const param2 = $('input#latest_list_news_other_params2').val(); - const response2 = await got({ - method: 'get', - url: urlPrefix + 'latest_list_news2/' + param2 + '/?action=latest_list_news2&others=' + param2, - }); - const data2 = response2.data; - const secondArticleList = cheerio.load(data2); - list = secondArticleList('article').add(firstArticleList('article')); + list = $('div#latest_list_news').find('article').append($('div#latest_list_news_more').find('article')); list = list.map((index, item) => { item = $(item); @@ -74,8 +57,9 @@ module.exports = async (ctx) => { } // format category name + let formattedCategoryName = categoryName; if (categoryName !== '') { - categoryName = ' - ' + categoryName.trim(); + formattedCategoryName = ' - ' + categoryName.trim(); } const items = await Promise.all( @@ -91,7 +75,7 @@ module.exports = async (ctx) => { } const description = await ctx.cache.tryGet(link, async () => { - const response = await got.get(link); + const response = await got(link); const $ = cheerio.load(response.data); const mainContent = $('div.p-main-contents'); // remove articles recomended @@ -120,6 +104,7 @@ module.exports = async (ctx) => { editorial: '社説', medical: '医療・健康', olympic: 'オリンピック', + koushitsu: '皇室', }; const tag_value = tag_table[link.split('/')[3]]; tag = tag_value ? tag_value : 'その他'; @@ -129,7 +114,7 @@ module.exports = async (ctx) => { return { title: tag + item.find('a').text(), description, - pubDate: timezone(new Date(item.find('time').prop('datetime')), +9), + pubDate: timezone(parseDate(item.find('time').prop('datetime')), +9), link, }; }) @@ -137,7 +122,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: '読売新聞' + categoryName, + title: '読売新聞' + formattedCategoryName, link: url, item: items, }; diff --git a/lib/v2/yomiuri/radar.js b/lib/v2/yomiuri/radar.js new file mode 100644 index 000000000..5030af25b --- /dev/null +++ b/lib/v2/yomiuri/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'yomiuri.co.jp': { + _name: '読売新聞', + www: [ + { + title: '読売新聞', + docs: 'https://docs.rsshub.app/traditional-media.html#du-mai-xin-wen', + source: ['/:category'], + target: '/yomiuri/:category', + }, + ], + }, +}; diff --git a/lib/v2/yomiuri/router.js b/lib/v2/yomiuri/router.js new file mode 100644 index 000000000..6f4894d9a --- /dev/null +++ b/lib/v2/yomiuri/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:category?', require('./news')); +};