feat: add 3 routes (#3434)

This commit is contained in:
Luyu Huang
2019-11-19 17:45:08 +08:00
committed by DIYgod
parent e031a54dfb
commit 0b48d388d8
10 changed files with 261 additions and 0 deletions
+42
View File
@@ -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',
},
],
},
});
+6
View File
@@ -229,6 +229,12 @@ pageClass: routes
<Route author="junfengP" path="/manhuadb/:id" example="/manhuadb/comics/1711" :paramsDesc="['漫画ID']"/>
## 三界异次元
### 三界异次元
<Route author="luyuhuang" example="/3ycy/home" path="/3ycy/home"/>
## 鼠绘漫画
### 鼠绘漫画
+10
View File
@@ -45,6 +45,16 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par
</RouteEn>
## Emi Nitta official website
### Recent update
<Route author="luyuhuang" example="/emi-nitta/updates" path="/emi-nitta/updates"/>
### News
<Route author="luyuhuang" example="/emi-nitta/news" path="/emi-nitta/news"/>
## EZTV
::: tip
+6
View File
@@ -3,3 +3,9 @@ pageClass: routes
---
# Shopping
## Alter China
### News
<Route author="luyuhuang" example="/alter-cn/news" path="/alter-cn/news"/>
+10
View File
@@ -375,6 +375,16 @@ type 为 all 时,category 参数不支持 cost 和 free
<Route author="kt286" example="/tprtc/news" path="/tprtc/news"/>
## 新田惠海官方网站
### 最近的更新
<Route author="luyuhuang" example="/emi-nitta/updates" path="/emi-nitta/updates"/>
### 新闻
<Route author="luyuhuang" example="/emi-nitta/news" path="/emi-nitta/news"/>
## 油价
### 今日油价
+6
View File
@@ -4,6 +4,12 @@ pageClass: routes
# 购物
## Alter 中国
### 新闻
<Route author="luyuhuang" example="/alter-cn/news" path="/alter-cn/news"/>
## Westore
### 新品
+9
View File
@@ -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'));
+52
View File
@@ -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,
};
};
+45
View File
@@ -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,
};
};
+75
View File
@@ -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,
};
};