feat: add hotukdeals

This commit is contained in:
DIYgod 2021-10-17 20:48:26 +01:00
parent 43e7e24899
commit 80aa29ff28
No known key found for this signature in database
GPG Key ID: D159328F47A80DCA
5 changed files with 52 additions and 0 deletions

View File

@ -48,6 +48,12 @@ Parameter `time` only works when `mostwanted` is chosen as the category.
<RouteEn author="nczitzk" example="/guiltfree/onsale" path="/guiltfree/onsale"/>
## hotukdeals
### thread
<Route author="DIYgod" example="/hotukdeals/hot" path="/hotukdeals/:type" :paramsDesc="['should be one of highlights, hot, new, discussed']" ></Route>
## IKEA
### UK - New Product Release

View File

@ -75,6 +75,12 @@ pageClass: routes
<Route author="nczitzk" example="/guiltfree/onsale" path="/guiltfree/onsale"/>
## hotukdeals
### thread
<Route author="DIYgod" example="/hotukdeals/hot" path="/hotukdeals/:type" :paramsDesc="['should be one of highlights, hot, new, discussed']" ></Route>
## LeBonCoin
### Ads

View File

@ -0,0 +1,34 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
let type = ctx.params.type;
if (type === 'highlights') {
type = '';
}
const data = await got.get(`https://www.hotukdeals.com/${type}?page=1&ajax=true&layout=horizontal`, {
headers: {
Referer: `https://www.hotukdeals.com/${type}`,
},
});
const $ = cheerio.load(data.data.data.content);
const list = $('article.thread');
ctx.state.data = {
title: `hotukdeals ${type}`,
link: `https://www.hotukdeals.com/${type}`,
item: list
.map((index, item) => {
item = $(item);
return {
title: item.find('.cept-tt').text(),
description: `${item.find('.cept-thread-image-link').html()}<br>${item.find('.cept-vote-temp').html()}<br>${item.find('.overflow--fade').html()}<br>${item.find('.cept-description-container').html()}`,
link: item.find('.cept-tt').attr('href'),
};
})
.get()
.reverse(),
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/:type': ['DIYgod'],
};

View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:type', require('./index'));
};