fix(route): duozhuayu (#12477)
This commit is contained in:
parent
803116654d
commit
48c624b2c6
|
|
@ -328,7 +328,7 @@ For instance, in <https://www.zagg.com/en_us/new-arrivals?brand=164&cat=3038%2C3
|
|||
|
||||
### 搜索结果
|
||||
|
||||
<Route author="fengkx" example="/duozhuayu/search/JavaScript" path="/duozhuayu/search/:wd" :paramsDesc="['搜索关键词']"/>
|
||||
<Route author="fengkx" example="/duozhuayu/search/JavaScript" path="/duozhuayu/search/:wd" :paramsDesc="['搜索关键词']" radar="1"/>
|
||||
|
||||
## 逛丢
|
||||
|
||||
|
|
|
|||
|
|
@ -1164,7 +1164,7 @@ router.get('/allpoetry/:order?', lazyloadRouteHandler('./routes/allpoetry/order'
|
|||
// router.get('/wallstreetcn/live/:channel?', lazyloadRouteHandler('./routes/wallstreetcn/live'));
|
||||
|
||||
// 多抓鱼搜索
|
||||
router.get('/duozhuayu/search/:wd', lazyloadRouteHandler('./routes/duozhuayu/search'));
|
||||
// router.get('/duozhuayu/search/:wd', lazyloadRouteHandler('./routes/duozhuayu/search'));
|
||||
|
||||
// 创业邦
|
||||
router.get('/cyzone/author/:id', lazyloadRouteHandler('./routes/cyzone/author'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/search/:wd': ['fengkx'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'duozhuayu.com': {
|
||||
_name: '多抓鱼',
|
||||
'.': [
|
||||
{
|
||||
title: '搜索结果',
|
||||
docs: 'https://docs.rsshub.app/shopping.html#duo-zhua-yu',
|
||||
source: ['/search/book/:wd'],
|
||||
target: '/duozhuayu/search/:wd',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/search/:wd', require('./search'));
|
||||
};
|
||||
|
|
@ -1,10 +1,14 @@
|
|||
const got = require('@/utils/got');
|
||||
const aesjs = require('aes-js');
|
||||
const queryString = require('query-string');
|
||||
const { art } = require('@/utils/render');
|
||||
const { join } = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const wd = ctx.params.wd;
|
||||
const link = `https://www.duozhuayu.com/search/${wd}`;
|
||||
const baseUrl = 'https://www.duozhuayu.com';
|
||||
const type = 'book';
|
||||
const link = `${baseUrl}/search/${type}/${wd}`;
|
||||
|
||||
// token获取见 https://github.com/wong2/userscripts/blob/master/duozhuayu.user.js
|
||||
const key = 'DkOliWvFNR7C4WvR'.split('').map((c) => c.charCodeAt());
|
||||
|
|
@ -24,48 +28,35 @@ module.exports = async (ctx) => {
|
|||
const token = encrypt([timestamp, userId, securityKey].join(':'));
|
||||
const requestId = [userId, timestamp, Math.round(1e5 * Math.random())].join('-');
|
||||
return {
|
||||
'x-timestamp': timestamp,
|
||||
'x-security-key': securityKey,
|
||||
'x-user-id': userId,
|
||||
'x-request-token': token,
|
||||
'x-request-misc': '{"platform":"browser"}',
|
||||
'x-api-version': '0.0.15',
|
||||
'x-request-id': requestId,
|
||||
'x-api-version': '0.0.48',
|
||||
'x-refer-request-id': requestId,
|
||||
'x-request-id': requestId,
|
||||
'x-request-misc': '{"platform":"browser","originSource":"search","originFrom":"normal","webVersion":"1.2.201774"}',
|
||||
'x-request-token': token,
|
||||
'x-security-key': securityKey,
|
||||
'x-timestamp': timestamp,
|
||||
'x-user-id': userId,
|
||||
};
|
||||
};
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://www.duozhuayu.com/api/search',
|
||||
searchParams: queryString.stringify({
|
||||
url: `${baseUrl}/api/search/book`,
|
||||
searchParams: {
|
||||
type: 'normal',
|
||||
q: wd,
|
||||
}),
|
||||
},
|
||||
headers: getCustomRequestHeaders(),
|
||||
});
|
||||
const books = response.data.data || [];
|
||||
|
||||
const item = books
|
||||
.filter((item) => item.type === 'book')
|
||||
.map((item) => {
|
||||
const book = item.book;
|
||||
return {
|
||||
title: book.title,
|
||||
link: `https://www.duozhuayu.com/books/${book.id}`,
|
||||
pubDate: new Date(book.updated).toUTCString(),
|
||||
description: `
|
||||
<img src="${book.images.origin}" ><br>
|
||||
书名:${book.title} ${book.originalTitle}<br>
|
||||
作者:${book.rawAuthor}<br>
|
||||
ISBN:${book.isbn13}<br>
|
||||
出版社:${book.publisher}<br>
|
||||
出版时间:${book.publishDate}<br>
|
||||
价格:${(book.price / 100).toFixed(2)}元起 <del>${(book.originalPrice / 100).toFixed(2)}元</del><br>
|
||||
`,
|
||||
guid: book.id,
|
||||
};
|
||||
});
|
||||
const item = response.data.data
|
||||
.filter((item) => item.type === type)
|
||||
.map(({ [type]: item }) => ({
|
||||
title: item.title,
|
||||
link: `${baseUrl}/books/${item.id}`,
|
||||
pubDate: parseDate(item.updated), // 2023-05-07T13:33:09+08:00
|
||||
description: art(join(__dirname, 'templates/book.art'), { item }),
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `多抓鱼搜索-${wd}`,
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<img src="{{ item.images.origin }}"><br>
|
||||
书名:{{ item.title }} {{ item.originalTitle }}<br>
|
||||
{{ if item.subtitle }}{{ item.subtitle }}<br>{{ /if }}
|
||||
作者:{{ item.rawAuthor }}<br>
|
||||
{{ if item.translators && item.translators.length }}译者:{{ item.translators.map((t) => t.name).join(' / ') }}<br>{{ /if }}
|
||||
ISBN:{{ item.isbn13 }}<br>
|
||||
出版社:{{ item.publisher }}<br>
|
||||
出版时间:{{ item.publishDate }}<br>
|
||||
豆瓣评分:{{ item.doubanRating }}<br>
|
||||
价格:{{ (item.price / 100).toFixed(2) }}元起 <del>{{ (item.originalPrice / 100).toFixed(2) }}元</del>
|
||||
Loading…
Reference in New Issue