feat: add pintu360

This commit is contained in:
DIYgod
2019-09-09 16:28:33 +08:00
parent 889f3118b1
commit 2ae32eac80
3 changed files with 72 additions and 0 deletions

View File

@@ -1324,3 +1324,17 @@ type 为 all 时category 参数不支持 cost 和 free
### 全文
<Route author="HenryQW" example="/zzz" path="/zzz/index"/>
## 品途商业评论
### 文章
<Route author="DIYgod" example="/pintu360/0" path="/pintu360/:type?" :paramsDesc="['类型, 默认为 `0` 推荐']">
类型
| 推荐 | 零售前沿 | 智能科技 | 泛文娱 | 教育 | 大健康 | 新消费 | 创业投资 |
| ---- | -------- | -------- | ------ | ---- | ------ | ------ | -------- |
| 0 | 7 | 10 | 9 | 98 | 70 | 8 | 72 |
</Route>

View File

@@ -1704,4 +1704,7 @@ router.get('/nfmovies/:id?', require('./routes/nfmovies/index'));
// 书友社区
router.get('/andyt/:view?', require('./routes/andyt/index'));
// 品途商业评论
router.get('/pintu360/:type?', require('./routes/pintu360/index'));
module.exports = router;

View File

@@ -0,0 +1,55 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const type = ctx.params.type || '0';
const response = await got({
method: 'post',
url: 'https://www.pintu360.com/service/ajax_article_service.php',
headers: {
Referer: 'https://www.pintu360.com/',
},
form: true,
data: {
fnName: 'getArticleList',
type: type === '0' ? 'recommend' : 'classId',
id: type,
pageNumber: 0,
duration: 'quarter',
},
});
const data = response.data;
const items = await Promise.all(
data.slice(0, 10).map(async (item) => {
const link = `https://www.pintu360.com/a${item.id}.html?${item.op}`;
return Promise.resolve({
title: item.title,
description: await ctx.cache.tryGet(link, async () => {
const res = await got(link);
const $ = cheerio.load(res.data);
return $('.article-content .text').html();
}),
pubDate: new Date(item.createTime).toUTCString(),
link,
});
})
);
const titleMap = {
'0': '推荐',
'7': '零售前沿',
'10': '智能科技',
'9': '泛文娱',
'98': '教育',
'70': '大健康',
'8': '新消费',
'72': '创业投资',
};
ctx.state.data = {
title: `品途商业评论-${titleMap[type]}`,
link: type === '0' ? 'https://www.pintu360.com/' : `https://www.pintu360.com/articleList-${type}.html`,
item: items,
};
};