parent
3a30d5d5a3
commit
8297348be4
|
|
@ -2185,6 +2185,30 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
|
|||
|
||||
<route name="最新" author="xyqfer" example="/coolbuy/newest" path="/coolbuy/newest"/>
|
||||
|
||||
### 京东众筹
|
||||
|
||||
<route name="众筹项目" author="LogicJake" example="/jingdong/zhongchou/all/zcz/zhtj" path="/jingdong/zhongchou/:type/:status/:sort" :paramsDesc="['类型','状态','排序方式']">
|
||||
|
||||
类型
|
||||
|
||||
| 全部 | 科技 | 美食 | 家电 | 设计 | 娱乐 | 文化 | 公益 | 其他 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| all | kj | ms | jd | sj | yl | wh | gy | qt |
|
||||
|
||||
状态
|
||||
|
||||
| 全部 | 预热中 | 众筹中 | 众筹成功 | 项目成功 |
|
||||
| ---- | ------ | ------ | -------- | -------- |
|
||||
| all | yrz | zcz | zccg | xmcg |
|
||||
|
||||
排序方式
|
||||
|
||||
| 综合推荐 | 最新上线 | 金额最多 | 支持最多 | 即将结束 |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| zhtj | zxsx | jezg | zczd | jjjs |
|
||||
|
||||
</route>
|
||||
|
||||
## 游戏资讯
|
||||
|
||||
### 3DMGame
|
||||
|
|
|
|||
|
|
@ -954,4 +954,6 @@ router.get('/patchwork.kernel.org/comments/:id', require('./routes/patchwork.ker
|
|||
// qdaily
|
||||
router.get('/qdaily', require('./routes/qdaily/index'));
|
||||
|
||||
// 京东众筹
|
||||
router.get('/jingdong/zhongchou/:type/:status/:sort', require('./routes/jingdong/zhongchou'));
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const contentUrl = 'https://z.jd.com/bigger/search.html';
|
||||
const host = 'https://z.jd.com/';
|
||||
const typeCodes = new Map([
|
||||
['all', { title: '京东众筹 -- 全部', code: '' }],
|
||||
['kj', { title: '京东众筹 -- 科技', code: 10 }],
|
||||
['ms', { title: '京东众筹 -- 美食', code: 36 }],
|
||||
['jd', { title: '京东众筹 -- 家电', code: 37 }],
|
||||
['sj', { title: '京东众筹 -- 设计', code: 12 }],
|
||||
['yl', { title: '京东众筹 -- 娱乐', code: 11 }],
|
||||
['wh', { title: '京东众筹 -- 文化', code: 38 }],
|
||||
['gy', { title: '京东众筹 -- 公益', code: 13 }],
|
||||
['qt', { title: '京东众筹 -- 其他', code: 14 }],
|
||||
]);
|
||||
|
||||
const statusCodes = {
|
||||
all: '',
|
||||
yrz: 1,
|
||||
zcz: 2,
|
||||
zccg: 4,
|
||||
xmcg: 8,
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 'all';
|
||||
const status = ctx.params.status || 'all';
|
||||
const sort = ctx.params.sort || 'zxsx';
|
||||
|
||||
const title = typeCodes.get(type).title;
|
||||
const typeCode = typeCodes.get(type).code;
|
||||
const statusCode = statusCodes[status];
|
||||
|
||||
const params = {
|
||||
sort: sort,
|
||||
};
|
||||
if (typeCode !== '') {
|
||||
params.categoryId = typeCode;
|
||||
}
|
||||
if (statusCode !== '') {
|
||||
params.status = statusCode;
|
||||
}
|
||||
const response = await axios({
|
||||
method: 'post',
|
||||
url: contentUrl,
|
||||
headers: {
|
||||
'Content-type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
params: params,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const out = $('body > div.wrap.mt20 > div.l-info > div.l-result > ul > li')
|
||||
.slice(0, 10)
|
||||
.map(function() {
|
||||
const image =
|
||||
'https:' +
|
||||
$(this)
|
||||
.find('a.link-pic > img')
|
||||
.attr('src');
|
||||
const information = $(this)
|
||||
.find('div.p-outter > div.p-items > ul')
|
||||
.html()
|
||||
.trim();
|
||||
const description = `<img src="${image}" referrerpolicy="no-referrer" /><br>${information}`;
|
||||
|
||||
const info = {
|
||||
link: url.resolve(
|
||||
host,
|
||||
$(this)
|
||||
.find('a.link-pic')
|
||||
.attr('href')
|
||||
),
|
||||
description: description,
|
||||
title:
|
||||
$(this)
|
||||
.find('div.i-tits.no-color-choose > a > h4')
|
||||
.text() ||
|
||||
$(this)
|
||||
.find('div.i-tits > a > h4')
|
||||
.text(),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: title,
|
||||
link: host,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue