feat(route): add ShopBack (#8565)
This commit is contained in:
parent
3b83b0ec4b
commit
77c15326bc
|
|
@ -88,6 +88,12 @@ All brands, see [Brand list](https://www.mercari.com/jp/brand/)
|
|||
|
||||
</RouteEn>
|
||||
|
||||
## ShopBack
|
||||
|
||||
### Store
|
||||
|
||||
<RouteEn author="nczitzk" example="/shopback/shopee-mart" path="/shopback/:store" :paramsDesc="['Store, can be found in URL']"/>
|
||||
|
||||
## The Independent
|
||||
|
||||
### PS5 stock UK
|
||||
|
|
|
|||
|
|
@ -105,6 +105,12 @@ For instance, in <https://www.leboncoin.fr/recherche/?**category=10&locations=Pa
|
|||
|
||||
</Route>
|
||||
|
||||
## ShopBack
|
||||
|
||||
### Store
|
||||
|
||||
<Route author="nczitzk" example="/shopback/shopee-mart" path="/shopback/:store" :paramsDesc="['店铺名,可在 URL 中找到']"/>
|
||||
|
||||
## The Independent
|
||||
|
||||
### PS5 stock UK
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:store': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'shopback.com.tw': {
|
||||
_name: 'ShopBack',
|
||||
'.': [
|
||||
{
|
||||
title: 'Store',
|
||||
docs: 'https://docs.rsshub.app/shopping.html#shopback-store',
|
||||
source: ['/:category', '/'],
|
||||
target: '/shopback/:store',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:store', require('./store'));
|
||||
};
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const store = ctx.params.store;
|
||||
|
||||
const rootUrl = 'https://www.shopback.com.tw';
|
||||
const currentUrl = `${rootUrl}/${store}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('table').remove();
|
||||
|
||||
const items = $('div[data-content-name]')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.attr('data-content-name'),
|
||||
author: item.attr('data-content-merchant'),
|
||||
description: `<p>${item.find('.mb-3').text()}</p>`,
|
||||
link: `${rootUrl}/login?redirect=/redirect/alink/${item.attr('data-content-id')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('h1').text()} - ShopBack`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue