feat: better format for hpoi
This commit is contained in:
parent
6a9ba55d2e
commit
57d825d156
|
|
@ -84,7 +84,7 @@ pageClass: routes
|
|||
|
||||
### 浏览周边
|
||||
|
||||
<Route author="howel52" path="/hpoi/:category/:words" example="/hpoi/charactar/1246512" :paramsDesc="['分类, 见下表', '关键词']">
|
||||
<Route author="howel52 DIYgod" path="/hpoi/:category/:words" example="/hpoi/charactar/1246512" :paramsDesc="['分类, 见下表', '关键词']">
|
||||
|
||||
| 角色手办 | 作品手办 |
|
||||
| --------- | -------- |
|
||||
|
|
|
|||
|
|
@ -17,25 +17,42 @@ const MAPs = {
|
|||
module.exports = async (ctx) => {
|
||||
const category = ctx.params && ctx.params.category;
|
||||
const words = ctx.params && ctx.params.words;
|
||||
const link = MAPs[category].url.replace(/{words}/, words);
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: MAPs[category].url.replace(/{words}/, words),
|
||||
url: link,
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
ctx.state.data = {
|
||||
title: MAPs[category].title + ' - ' + $('title').text(),
|
||||
title:
|
||||
'Hpoi 手办维基' +
|
||||
' - ' +
|
||||
$(`#${category}`)
|
||||
.text()
|
||||
.trim(),
|
||||
link: link,
|
||||
item: $('.bs-glyphicons-list .detail-grid')
|
||||
.map((_index, _item) => {
|
||||
_item = $(_item);
|
||||
return {
|
||||
title: _item.find('.detail-grid-title').text(),
|
||||
link: host + '/' + _item.find('.detail-grid-title a').attr('href'),
|
||||
description: _item.find('.detail-grid-info').text(),
|
||||
description: `<img referrerpolicy="no-referrer" src="${_item.find('.thumbnail img').attr('src')}">${_item
|
||||
.find('.detail-grid-info span')
|
||||
.eq(0)
|
||||
.text()}<br>${_item
|
||||
.find('.detail-grid-info span')
|
||||
.eq(1)
|
||||
.text()}<br>${_item
|
||||
.find('.detail-grid-info span')
|
||||
.eq(2)
|
||||
.text()}`,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
.get()
|
||||
.reverse(),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue