mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 08:10:32 +08:00
feat: add guiltfree onsale (#5517)
Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
@@ -10,6 +10,12 @@ pageClass: routes
|
||||
|
||||
<RouteEn author="luyuhuang" example="/alter-cn/news" path="/alter-cn/news"/>
|
||||
|
||||
## Guiltfree.pl
|
||||
|
||||
### Onsale
|
||||
|
||||
<RouteEn author="nczitzk" example="/guiltfree/onsale" path="/guiltfree/onsale"/>
|
||||
|
||||
## IKEA
|
||||
|
||||
### UK - New Product Release
|
||||
|
||||
@@ -24,6 +24,12 @@ pageClass: routes
|
||||
|
||||
<Route author="NeverBehave" example="/furstar/artists/cn" path="/furstar/artists/:lang?" :paramsDesc="['语言, 留空为jp, 支持cn, en']"/>
|
||||
|
||||
## Guiltfree.pl
|
||||
|
||||
### Onsale
|
||||
|
||||
<Route author="nczitzk" example="/guiltfree/onsale" path="/guiltfree/onsale"/>
|
||||
|
||||
## LeBonCoin
|
||||
|
||||
### Ads
|
||||
|
||||
@@ -3119,6 +3119,9 @@ router.get('/fjnews/fz/30', require('./routes/fjnews/fznews'));
|
||||
// 九江新闻jjnews
|
||||
router.get('/fjnews/jjnews', require('./routes/fjnews/jjnews'));
|
||||
|
||||
// Guiltfree
|
||||
router.get('/guiltfree/onsale', require('./routes/guiltfree/onsale'));
|
||||
|
||||
// 消费明鉴
|
||||
router.get('/mingjian', require('./routes/mingjian/index'));
|
||||
|
||||
|
||||
49
lib/routes/guiltfree/onsale.js
Normal file
49
lib/routes/guiltfree/onsale.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = 'https://www.guiltfree.pl/pl/onsale';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('#prodlistx ul li')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a.product-name');
|
||||
return {
|
||||
title: item.find('span.name_list').text(),
|
||||
link: a.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.cartqtyrow').remove();
|
||||
content('#accessoriesblock').remove();
|
||||
content('#crossselling_block').remove();
|
||||
|
||||
item.description = content('#center_column').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Guiltfree.pl - Wyprzedaże',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user