diff --git a/docs/traditional-media.md b/docs/traditional-media.md index b359f7dbd..fc1ee8ac8 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1020,59 +1020,85 @@ category 对应的关键词有 -## 朝日新聞中文網(繁體中文版) +## 朝日新聞デジタル -### 新聞分類 +::: tip 提示 - +朝日新闻中文网已于 2021 年 3 月 31 日关闭。 -版块: +::: -| society | politics_economy | cool_japan | travel | sports | business | technology | world | opinion | whatsnew | -| -------- | ---------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | -------- | -| 國內綜合 | 政治・經濟 | 文化・生活 | 旅遊・活動 | 體育・奧運 | 商業・商品 | IT ・科技 | 國際・東亞 | 評論・專欄 | 最新消息 | +### 新聞 -版块 `cool_japan` 和 `travel` 包含子版块: + -`cool_japan`: +::: tip 提示 -| entertainment | anime | life | style_culture | -| ------------- | ----- | ---------- | ------------- | -| 藝能 | 動漫 | 生活・美食 | 時尚・藝文 | +以下小标题即类型 `genre`,标题下表格中为对应类型的分类 `category`,两者需要配合使用。 -`travel`: +如订阅 **社会** 类型中的 **事件・事故・裁判** 分类,填入 [`/asahi/national/incident`](http://rsshub.app/asahi/national/incident)。 -| news | scenery | topic | move | -| ---- | ------- | ----- | ---- | -| 資訊 | 風景 | 體驗 | 交通 | +若类型下没有分类,如 **トップ** 类型,直接填入 [`/asahi/top`](http://rsshub.app/asahi/top)。 - +或者欲订阅该类型下的所有分类,如订阅 **社会** 中的所有分类,则直接将分类 `category` 留空,即 [`/asahi/national`](http://rsshub.app/asahi/national)。 -## 朝日新聞中文网(简体中文版) +::: -### 新闻分类 +トップ top - +社会 national -版块: +| 事件・事故・裁判 | 災害・交通情報 | その他・話題 | おくやみ | +| ---------------- | -------------- | ------------ | ---------- | +| incident | calamity | etc | obituaries | -| society | politics_economy | cool_japan | travel | sports | business | technology | world | opinion | whatsnew | -| -------- | ---------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- | -------- | -| 日本社会 | 政治・经济 | 文娱・生活 | 旅游・活动 | 体育・奥运 | 商务・商品 | IT ・科技 | 国际・东亚 | 观点・专栏 | 最新 | +経済 business -版块 `cool_japan` 和 `travel` 包含子版块: +| 産業・商品 | 金融・財政 | 経済政策 | 労働・雇用 | 市況・統計 | +| ---------- | ---------- | -------------- | ---------- | ---------- | +| industry | finance | economicpolicy | work | statistics | -`cool_japan`: +政治 politics -| entertainment | anime | life | style_culture | -| ------------- | ----- | ---------- | ------------- | -| 艺能 | 动漫 | 生活・美食 | 时尚・文化 | +| 国政 | 地方政治 | 発言録 | 世論調査 | +| ---------- | -------- | ------------ | -------- | +| government | local | hatsugenroku | yoron | -`travel`: +国際 international -| news | scenery | topic | move | -| ---- | ------- | ----- | ---- | -| 资讯 | 风景 | 体验 | 交通 | +| アジア・太平洋 | 北米 | 中南米 | ヨーロッパ | 中東 | アフリカ | 国連・その他 | +| -------------- | -------- | -------- | ---------- | ---------- | -------- | ------------ | +| asia | namerica | samerica | europe | middleeast | africa | etc | + +スポーツ sports + +| 野球 | サッカー | 相撲 | フィギュア | ゴルフ | 一般スポーツ | 東京オリンピック 2020 | 東京パラリンピック 2020 | +| -------- | -------- | ---- | ------------------ | ------ | ------------ | --------------------- | ----------------------- | +| baseball | soccer | sumo | winter_figureskate | golf | general | olympics | paralympics | + +IT・科学 tech_science + +| 環境・エネルギー | 科学 | デジもの | 企業・サービス | 製品ファイル | +| ---------------- | ------- | -------- | -------------- | ------------ | +| eco | science | digital | service | products | + +文化・芸能 culture + +| 映画 | 音楽 | アイドル | アート | テレビ・芸能 | 舞台・演芸 | マンガ・アニメ・ゲーム | ひと・歴史 | 囲碁 | 将棋 | +| ------ | ----- | -------- | ------ | ------------ | ---------- | ---------------------- | ---------- | ---- | ------ | +| movies | music | idol | art | showbiz | stage | manga | history | igo | shougi | + +ライフ life + +| 介護 | 働き方・就活 | 食・料理 | +| --------- | ------------ | -------- | +| eldercare | hataraku | food | + +教育・子育て edu + +| 小中高 | 大学 | 教育制度・話題 | 教育問題 | 地域の教育ニュース | 吹奏楽 | 合唱 | 子育て | ハグスタ | +| ------- | ---------- | -------------- | -------- | ------------------ | --------- | ------ | -------- | -------- | +| student | university | system | issue | chiiki | suisogaku | gassho | hagukumu | msta | diff --git a/lib/router.js b/lib/router.js index ece0ed9ce..3de3e1d00 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1716,13 +1716,10 @@ router.get('/the-economist/:endpoint', require('./routes/the-economist/full')); // 鼠绘漫画 router.get('/shuhui/comics/:id', require('./routes/shuhui/comics')); -// 朝日新聞中文网(简体中文版) -router.get('/asahichinese-j/:category/:subCate', require('./routes/asahichinese-j/index')); -router.get('/asahichinese-j/:category', require('./routes/asahichinese-j/index')); - -// 朝日新聞中文網(繁體中文版) -router.get('/asahichinese-f/:category/:subCate', require('./routes/asahichinese-f/index')); -router.get('/asahichinese-f/:category', require('./routes/asahichinese-f/index')); +// 朝日新闻 +router.get('/asahi/:genre?/:category?', require('./routes/asahi/index')); +router.get('/asahichinese-j/:genre?/:category?', require('./routes/asahi/index')); +router.get('/asahichinese-f/:genre?/:category?', require('./routes/asahi/index')); // 7x24小时快讯 router.get('/fx678/kx', require('./routes/fx678/kx')); diff --git a/lib/routes/asahi/index.js b/lib/routes/asahi/index.js new file mode 100644 index 000000000..ecb41fe95 --- /dev/null +++ b/lib/routes/asahi/index.js @@ -0,0 +1,82 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const categories = { + obituaries: '/obituaries', + yoron: '/politics/yoron', + baseball: '/sports/baseball', + soccer: '/sports/soccer', + sumo: '/sports/sumo', + winter_figureskate: '/sports/winter/figureskate', + golf: '/sports/golf', + general: '/sports/general', + olympics: '/olympics', + paralympics: '/paralympics', + eco: '/eco', + igo: '/igo', + shougi: '/shougi', + eldercare: '/national/eldercare', + hataraku: '/special/hataraku', + food: '/culture/food', + gassho: '/edu/gassho', + suisogaku: '/edu/suisogaku', + hagukumu: '/edu/hagukumu', + msta: '/msta', +}; + +module.exports = async (ctx) => { + const genre = ctx.params.genre || ''; + const category = ctx.params.category || ''; + + const rootUrl = 'https://www.asahi.com'; + const currentUrl = `${rootUrl}${genre ? `${category ? `${category in categories ? categories[category] : `/${genre}/list/${category}.html`}` : `/${genre}`}` : '/news/history.html'}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + $('.Time').remove(); + + const list = $('#MainInner .Section .List li a') + .slice(0, 6) + .map((_, item) => { + item = $(item); + const link = item.attr('href'); + + return { + link: link.indexOf('//') < 0 ? `${rootUrl}${link}` : `https:${link}`, + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + content('._30SFw, .-Oj2D, .notPrint').remove(); + + item.description = content('._3YqJ1').html(); + item.title = content('meta[name="TITLE"]').attr('content'); + item.pubDate = Date.parse(content('meta[name="pubdate"]').attr('content')); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + description: '朝日新聞社のニュースサイト、朝日新聞デジタルの社会ニュースについてのページです', + }; +}; diff --git a/lib/routes/asahichinese-f/index.js b/lib/routes/asahichinese-f/index.js deleted file mode 100644 index f306f5884..000000000 --- a/lib/routes/asahichinese-f/index.js +++ /dev/null @@ -1,102 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const logger = require('@/utils/logger'); - -const categoryCodes = new Map([ - ['society', { name: '國內綜合', types: {} }], - ['politics_economy', { name: '政治・經濟', types: {} }], - [ - 'cool_japan', - { - name: '文化・生活', - types: { - entertainment: '藝能', - anime: '動漫', - life: '生活・美食', - style_culture: '時尚・藝文', - }, - }, - ], - [ - 'travel', - { - name: '旅遊・活動', - types: { - news: '資訊', - scenery: '風景', - topic: '體驗', - move: '交通', - }, - }, - ], - ['sports', { name: '體育・奧運', types: {} }], - ['business', { name: '商業・商品', types: {} }], - ['technology', { name: 'IT・科技', types: {} }], - ['world', { name: '國際・東亞', types: {} }], - ['opinion', { name: '評論・專欄', types: {} }], - ['whatsnew', { name: '最新消息', types: {} }], -]); - -const host = 'https://asahichinese-f.com'; - -module.exports = async (ctx) => { - const category = ctx.params.category; - const type = ctx.params.subCate; - let iTitle = categoryCodes.get(category).name; - - let link = `https://asahichinese-f.com/${category}/`; - if (type !== undefined) { - link = link + `${type}/`; - iTitle = iTitle + '-' + categoryCodes.get(category).types[type]; - } - - const response = await got.get(link); - - const $ = cheerio.load(response.data); - - const list = $('ul.List li') - .slice(1, 11) - .map(function () { - const info = { - title: $(this).find('a').text(), - link: $(this).find('a').attr('href'), - date: $(this).find('span.Date').text(), - }; - logger.info(info.date); - return info; - }) - .get(); - - const out = await Promise.all( - list.map(async (info) => { - const title = info.title; - const date = info.date; - const itemUrl = host + info.link; - - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const response = await got.get(itemUrl); - - const $ = cheerio.load(response.data); - const description = $('div.ArticleText').html().trim(); - - const single = { - title: title, - link: itemUrl, - description: description, - pubDate: new Date(date).toUTCString(), - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title: `${iTitle}-朝日新聞中文網`, - link: link, - item: out, - }; -}; diff --git a/lib/routes/asahichinese-j/index.js b/lib/routes/asahichinese-j/index.js deleted file mode 100644 index 924881d23..000000000 --- a/lib/routes/asahichinese-j/index.js +++ /dev/null @@ -1,102 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const logger = require('@/utils/logger'); - -const categoryCodes = new Map([ - ['society', { name: '日本社会', types: {} }], - ['politics_economy', { name: '政治・经济', types: {} }], - [ - 'cool_japan', - { - name: '文娱・生活', - types: { - entertainment: '艺能', - anime: '动漫', - life: '生活・美食', - style_culture: '时尚・文化', - }, - }, - ], - [ - 'travel', - { - name: '旅游・活动', - types: { - news: '资讯', - scenery: '风景', - topic: '体验', - move: '交通', - }, - }, - ], - ['sports', { name: '体育・奥运', types: {} }], - ['business', { name: '商务・商品', types: {} }], - ['technology', { name: 'IT・科技', types: {} }], - ['world', { name: '国际・东亚', types: {} }], - ['opinion', { name: '观点・专栏', types: {} }], - ['whatsnew', { name: '最新', types: {} }], -]); - -const host = 'https://asahichinese-j.com'; - -module.exports = async (ctx) => { - const category = ctx.params.category; - const type = ctx.params.subCate; - let iTitle = categoryCodes.get(category).name; - - let link = `https://asahichinese-j.com/${category}/`; - if (type !== undefined) { - link = link + `${type}/`; - iTitle = iTitle + '-' + categoryCodes.get(category).types[type]; - } - - const response = await got.get(link); - - const $ = cheerio.load(response.data); - - const list = $('ul.List li') - .slice(1, 11) - .map(function () { - const info = { - title: $(this).find('a').text(), - link: $(this).find('a').attr('href'), - date: $(this).find('span.Date').text(), - }; - logger.info(info.date); - return info; - }) - .get(); - - const out = await Promise.all( - list.map(async (info) => { - const title = info.title; - const date = info.date; - const itemUrl = host + info.link; - - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const response = await got.get(itemUrl); - - const $ = cheerio.load(response.data); - const description = $('div.ArticleText').html().trim(); - - const single = { - title: title, - link: itemUrl, - description: description, - pubDate: new Date(date).toUTCString(), - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title: `${iTitle}-朝日新聞中文网`, - link: link, - item: out, - }; -};