feat: 新增 一兜糖 (#2684)

* fix docs format error

* feat: 新增一兜糖
This commit is contained in:
sanmmmm 2019-07-26 10:52:52 +08:00 committed by DIYgod
parent 5e9c6726e8
commit c0d993b4fa
8 changed files with 193 additions and 12 deletions

View File

@ -939,6 +939,7 @@ type 为 all 时category 参数不支持 cost 和 free
| (空) | My01 | My02 | My03 | My04 |
</Route>
## 维基百科
### 中国大陆新闻动态
@ -1054,6 +1055,31 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="zhuan-zhu" example="/mpaypass/main/policy" path="mpaypass/main/:type?"
:paramsDesc="['新闻类型,类型可在URL中找到类似policyeye等空或其他任意值展示最新新闻']"/>
## 一兜糖
### 首页精选
<Route author="sanmmm" example="/yidoutang/index" path="/yidoutang/index"/>
### 文章
<Route author="sanmmm" example="/yidoutang/guide" path="/yidoutang/guide"/>
### 众测
<Route author="sanmmm" example="/yidoutang/mtest" path="/yidoutang/mtest"/>
### 全屋记
<Route author="sanmmm" example="/yidoutang/case/:type?" path="/yidoutang/case/hot" :paramsDesc="['类型, 默认为`default`']">
类型
| 默认 | 最热 | 最新 |
| ------- | ---- | ---- |
| default | hot | new |
</Route>
## 油价
### 今日油价

View File

@ -4,6 +4,12 @@ pageClass: routes
# 购物
## Artand
### 用户新作
<Route author="junbaor" example="/artand/user/work/672" path="/artand/user/work/:uid" :paramsDesc="['用户ID, 不太好找, 自行抓包研究吧']"/>
## Westore
### 新品
@ -159,9 +165,3 @@ pageClass: routes
### 小米有品每日上新
<Route author="xyqfer" example="/mi/youpin/new" path="/mi/youpin/new"/>
## Artand
### 用户新作
<Route author="junbaor" example="/artand/user/work/672" path="/artand/user/work/:uid" :paramsDesc="['用户ID, 不太好找, 自行抓包研究吧']"/>

View File

@ -404,6 +404,12 @@ category 列表:
</Route>
## 南京工业大学
### 南京工业大学教务处
<Route author="TrumanGu" example="/njtech/jwc" path="/njtech/jwc" />
## 南京航空航天大学
### 教务通知
@ -954,9 +960,3 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
### 数据科学与计算机学院动态
<Route author="MegrezZhu" example="/sysu/sdcs" path="/sysu/sdcs" />
## 南京工业大学
### 南京工业大学教务处
<Route author="TrumanGu" example="/njtech/jwc" path="/njtech/jwc" />

View File

@ -1562,4 +1562,10 @@ router.get('/10000link/news/:category?', require('./routes/10000link/news'));
// Artand
router.get('/artand/user/work/:uid', require('./routes/artand/user/work'));
// 一兜糖
router.get('/yidoutang/index', require('./routes/yidoutang/index.js'));
router.get('/yidoutang/guide', require('./routes/yidoutang/guide.js'));
router.get('/yidoutang/mtest', require('./routes/yidoutang/mtest.js'));
router.get('/yidoutang/case/:type', require('./routes/yidoutang/case.js'));
module.exports = router;

View File

@ -0,0 +1,46 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const { type = 'default' } = ctx.params;
const urlPath = {
default: '',
hot: '/0-2-0-0-0-0/',
new: '/0-1-0-0-0-0/',
}[type];
const url = `http://www.yidoutang.com/case${urlPath}`;
const response = await got(url);
const $ = cheerio.load(response.data);
const items = $('.main .case-items > .case-item')
.map((_, ele) => {
const $item = cheerio.load(ele);
const baseInfoNode = $item('.info > .text');
const title = baseInfoNode.find('.title').text();
const desc = baseInfoNode.find('.desc').text();
const link = baseInfoNode.find('a').attr('href');
const thumbnail = $item('.img-box img').attr('src');
const author = $item('.user a').text();
return {
title,
link,
description: [`简介: ${desc}`, `<img src="${thumbnail}"/>`].join('<br/>'),
author,
};
})
.get();
const typeLabel = {
default: '默认',
hot: '热门',
new: '最新',
}[type];
ctx.state.data = {
title: `一兜糖 - 全屋记 - ${typeLabel}`,
description: `一兜糖 - 全屋记 - ${typeLabel}`,
link: url,
item: items,
};
};

View File

@ -0,0 +1,36 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = 'http://www.yidoutang.com/guide.html';
const response = await got(url);
const $ = cheerio.load(response.data);
const items = $('.main .guide-items > .guide-item')
.map((_, ele) => {
const $item = cheerio.load(ele);
const titleNode = $item('.title > a').first();
const title = titleNode.text();
const link = titleNode.attr('href');
const thumbnail = $item('a > img')
.first()
.attr('src');
const infoNode = $item('.info');
const desc = infoNode.find('.desc').text();
const author = infoNode.find('.user a').text();
return {
title,
link,
description: [`简介: ${desc}`, `<img src="${thumbnail}"/>`].join('<br/>'),
author,
};
})
.get();
ctx.state.data = {
title: '一兜糖 - 文章',
description: '一兜糖 - 文章',
link: url,
item: items,
};
};

View File

@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = 'http://www.yidoutang.com/';
const response = await got(url);
const $ = cheerio.load(response.data);
const items = $('.main > .article')
.map((_, ele) => {
const $item = cheerio.load(ele);
const baseInfoNode = $item('.title > a');
const title = baseInfoNode.text();
const link = baseInfoNode.attr('href');
const thumbnail = $item('.article > a > img').attr('delayload');
const desc = $item('.abstract').text();
const tip = $item('.tip').text();
const author = $item('.avatar a').text();
return {
title,
link,
description: [`分类: ${tip}`, `简介: ${desc}`, `<img src="${thumbnail}"/>`].join('<br/>'),
author,
};
})
.get();
ctx.state.data = {
title: '一兜糖 - 精选',
description: '一兜糖 - 精选',
link: url,
item: items,
};
};

View File

@ -0,0 +1,34 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = 'http://www.yidoutang.com/mtest';
const response = await got(url);
const $ = cheerio.load(response.data);
const items = $('.zc-bd .zc-bd-left > .clearfix > a')
.map((_, ele) => {
const $item = cheerio.load(ele);
const link = ele.attribs.href;
const thumbnail = $item('.top > img').attr('src');
const deadline = $item('.top > .time').text();
const otherInfoArr = $item('.bottom')
.text()
.trim()
.split('\n');
const title = otherInfoArr[0];
return {
title,
link,
description: [deadline, ...otherInfoArr, `<img src="${thumbnail}"/>`].filter((str) => !!str.trim()).join('<br/>'),
};
})
.get();
ctx.state.data = {
title: '一兜糖 - 众测',
description: '一兜糖 - 众测',
link: url,
item: items,
};
};