diff --git a/assets/radar-rules.js b/assets/radar-rules.js index f284a890a5..3d5c414d34 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -747,4 +747,46 @@ }, ], }, + + '3ycy.com': { + _name: '三界异次元', + www: [ + { + title: '最近更新', + docs: 'https://docs.rsshub.app/anime.html#san-jie-yi-ci-yuan', + source: '/', + target: '/3ycy/home', + }, + ], + }, + + 'emi-nitta.net': { + _name: 'Emi Nitta', + '.': [ + { + title: '最近更新', + docs: 'https://docs.rsshub.app/other.html#xin-tian-hui-hai-guan-fang-wang-zhan', + source: '/updates', + target: '/emi-nitta/updates', + }, + { + title: '新闻', + docs: 'https://docs.rsshub.app/other.html#xin-tian-hui-hai-guan-fang-wang-zhan', + source: '/contents/news', + target: '/emi-nitta/news', + }, + ], + }, + + 'alter-shanghai.cn': { + _name: 'Alter', + '.': [ + { + title: '新闻', + docs: 'https://docs.rsshub.app/shopping.html#alter-zhong-guo', + source: '/cn/news.html', + target: '/alter-cn/news', + }, + ], + }, }); diff --git a/docs/anime.md b/docs/anime.md index 9f16404d71..f2c496e745 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -229,6 +229,12 @@ pageClass: routes +## 三界异次元 + +### 三界异次元 + + + ## 鼠绘漫画 ### 鼠绘漫画 diff --git a/docs/en/other.md b/docs/en/other.md index c6349ba410..18b4f39890 100644 --- a/docs/en/other.md +++ b/docs/en/other.md @@ -45,6 +45,16 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par +## Emi Nitta official website + +### Recent update + + + +### News + + + ## EZTV ::: tip diff --git a/docs/en/shopping.md b/docs/en/shopping.md index 4d5da9ad9e..9fc7e05496 100644 --- a/docs/en/shopping.md +++ b/docs/en/shopping.md @@ -3,3 +3,9 @@ pageClass: routes --- # Shopping + +## Alter China + +### News + + diff --git a/docs/other.md b/docs/other.md index 5fa994acad..8840faaf3e 100644 --- a/docs/other.md +++ b/docs/other.md @@ -375,6 +375,16 @@ type 为 all 时,category 参数不支持 cost 和 free +## 新田惠海官方网站 + +### 最近的更新 + + + +### 新闻 + + + ## 油价 ### 今日油价 diff --git a/docs/shopping.md b/docs/shopping.md index 09300e76b3..d7ef3fb018 100644 --- a/docs/shopping.md +++ b/docs/shopping.md @@ -4,6 +4,12 @@ pageClass: routes # 购物 +## Alter 中国 + +### 新闻 + + + ## Westore ### 新品 diff --git a/lib/router.js b/lib/router.js index 74692f3479..5a6bea4338 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1935,6 +1935,15 @@ router.get('/gov/cnca/hydt', require('./routes/gov/cnca/hydt')); router.get('/gov/cnca/zxtz', require('./routes/gov/cnca/zxtz')); +// 三界异次元 +router.get('/3ycy/home', require('./routes/3ycy/home.js')); + +// Emi Nitta official website +router.get('/emi-nitta/:type', require('./routes/emi-nitta/home')); + +// Alter China +router.get('/alter-cn/news', require('./routes/alter-cn/news')); + // Visual Studio Code Marketplace router.get('/vscode/marketplace/:type?', require('./routes/vscode/marketplace')); diff --git a/lib/routes/3ycy/home.js b/lib/routes/3ycy/home.js new file mode 100644 index 0000000000..e1f5199c50 --- /dev/null +++ b/lib/routes/3ycy/home.js @@ -0,0 +1,52 @@ +const url = require('url'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const root_url = 'http://www.3ycy.com'; + const response = await got({ + method: 'get', + url: root_url, + }); + + const $ = cheerio.load(response.data); + const list = $('div.postList div.postItem'); + + const count = []; + for (let i = 0; i < Math.min(list.length, 10); ++i) { + count.push(i); + } + + const items = await Promise.all( + count.map(async (i) => { + const item = $(list[i]); + const title = item.find('h3 a').first(); + const link = title.attr('href'); + + return await ctx.cache.tryGet('3ycy' + link, async () => { + const date = item + .find('div.postSubtitle') + .text() + .trim(); + const match = /(\d+\/\d+\/\d{4}\s+\d+:\d+:\d+\s*(?:AM|PM))/i.exec(date); + const pubDate = match && new Date(match[1] + ' GMT+8').toUTCString(); + + const res = await got({ method: 'get', url: url.resolve(root_url, link) }); + const content = cheerio.load(res.data); + + return { + title: title.text(), + link: link, + pubDate: pubDate, + description: content('div.postBody').html(), + }; + }); + }) + ); + + ctx.state.data = { + title: '三界异次元', + link: root_url, + item: items, + }; +}; diff --git a/lib/routes/alter-cn/news.js b/lib/routes/alter-cn/news.js new file mode 100644 index 0000000000..53d9cf99db --- /dev/null +++ b/lib/routes/alter-cn/news.js @@ -0,0 +1,45 @@ +const url = require('url'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const root_url = 'http://alter-shanghai.cn'; + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: url.resolve(root_url, '/cn/news.html'), + }); + + const $ = cheerio.load(response.data); + const list = $('ul.listnews li') + .slice(0, 10) + .map((_, item) => { + item = $(item); + const a = item.find('a'); + const m = /(\d{4}-\d+-\d+)/.exec(item.find('span').text()); + return { + title: a.text(), + link: a.attr('href'), + pubDate: m && new Date(m[1] + ' GMT+8').toUTCString(), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet('alter-cn' + item.link, async () => { + const res = await got({ method: 'get', url: url.resolve(root_url, item.link) }); + const content = cheerio.load(res.data); + item.description = content(content('div.con table.table3')[1]).html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: 'Alter Shanghai', + link: root_url, + item: items, + }; +}; diff --git a/lib/routes/emi-nitta/home.js b/lib/routes/emi-nitta/home.js new file mode 100644 index 0000000000..bc68c8e954 --- /dev/null +++ b/lib/routes/emi-nitta/home.js @@ -0,0 +1,75 @@ +const url = require('url'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const root_url = 'https://emi-nitta.net'; + +const config = { + updates: { + link: '/updates', + title: 'Emi Nitta - Updates', + description: 'Recent update of Emi Nitta official website', + }, + + news: { + link: '/contents/news', + title: 'Emi Nitta - News', + description: 'News of Emi Nitta', + }, +}; + +const get_date = (o) => { + let date; + const match = /(\d{4}\.\d+\.\d+)/.exec(o.text().trim()); + if (match) { + date = match[1]; + } else { + date = o.attr('datetime'); + } + return new Date(date + ' GMT+9').toUTCString(); +}; + +module.exports = async (ctx) => { + const cfg = config[ctx.params.type]; + if (!cfg) { + throw Error('Bad type'); + } + + const response = await got({ + method: 'get', + url: url.resolve(root_url, cfg.link), + }); + + const $ = cheerio.load(response.data); + const list = $('article.details ul.list-unstyled li a') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.find('div.title h3').text(), + link: item.attr('href'), + pubDate: get_date(item.find('time')), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet('emi-nitta' + item.link, async () => { + const res = await got({ method: 'get', url: url.resolve(root_url, item.link) }); + const content = cheerio.load(res.data); + + item.description = content('article.details div.body').html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: cfg.title, + description: cfg.description, + link: root_url, + item: items, + }; +};