feat: add ptpress book (#4577)
This commit is contained in:
@@ -105,6 +105,12 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par
|
||||
|
||||
<Route author="kt286" example="/queshu/book/34626813" path="/queshu/book/:bookid" :paramsDesc="['图书ID,可在链接中获取']"/>
|
||||
|
||||
## 人民邮电出版社
|
||||
|
||||
### 图书列表
|
||||
|
||||
<Route author="hoilc" example="/ptpress/book/new" path="/ptpress/book/:type?" :paramsDesc="['排序方式,默认`new`为最新图书,可选`hot`为最热图书']"/>
|
||||
|
||||
## 什么值得买
|
||||
|
||||
::: tip 提示
|
||||
|
||||
@@ -2576,6 +2576,9 @@ router.get('/zhuixinfan/list', require('./routes/zhuixinfan/list'));
|
||||
// scoresaber
|
||||
router.get('/scoresaber/user/:id', require('./routes/scoresaber/user'));
|
||||
|
||||
// 人民邮电出版社
|
||||
router.get('/ptpress/book/:type?', require('./routes/ptpress/book'));
|
||||
|
||||
// 本地宝焦点资讯
|
||||
router.get('/bendibao/news/:city', require('./routes/bendibao/news'));
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type !== 'hot' ? 'publish' : 'hot';
|
||||
|
||||
const search_page_url = `https://www.ptpress.com.cn/shopping/search?tag=search&orderStr=${type}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: 'https://www.ptpress.com.cn/bookinfo/getBookListForEBTag',
|
||||
headers: {
|
||||
Referer: search_page_url,
|
||||
},
|
||||
form: {
|
||||
page: 1,
|
||||
rows: 18,
|
||||
orderStr: type,
|
||||
},
|
||||
});
|
||||
|
||||
const list = response.data.data.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `最${type === 'hot' ? '热' : '新'}图书 - 人民邮电出版社`,
|
||||
link: search_page_url,
|
||||
item: list.map((item) => ({
|
||||
title: `${item.bookName} / ¥${item.discountPrice}`,
|
||||
author: item.author,
|
||||
description: `<img src="${item.picPath}">`,
|
||||
pubDate: new Date(item.stockInDate.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3')),
|
||||
link: `https://www.ptpress.com.cn/shopping/buy?bookId=${item.bookId}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user