feat: youzan/weidian title replace userid to shopname (#3017)
This commit is contained in:
parent
6842c76de1
commit
3b442f3c84
|
|
@ -1,4 +1,5 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = String(ctx.params.id);
|
||||
|
|
@ -6,6 +7,10 @@ module.exports = async (ctx) => {
|
|||
const link = `https://weidian.com/?userid=${id}`;
|
||||
const api_link = `https://thor.weidian.com/ares/shop.getItemsInShop/1.0?param={"shopId":"${id}","tabId":3,"sortOrder":"desc","limit":20,"page":1}`;
|
||||
|
||||
const shopresponse = await got.get(link);
|
||||
const $ = cheerio.load(shopresponse.data);
|
||||
const shopname = $('.shop-name').text();
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: api_link,
|
||||
|
|
@ -25,7 +30,7 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${id} 商铺上新`,
|
||||
title: `${shopname || id} 商铺上新`,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = String(ctx.params.id);
|
||||
|
||||
const link = `https://h5.youzan.com/wscshop/feature/goods/all?kdt_id=${id}`;
|
||||
const link = `https://h5.youzan.com/wscshop/showcase/homepage?kdt_id=${id}`;
|
||||
const api_link = `https://h5.youzan.com/wscshop/showcase/goods/allGoods.json?pageSize=20&page=1&offlineId=0&order=&order_by=createdTime&kdt_id=${id}`;
|
||||
|
||||
const shopresponse = await got.get(link);
|
||||
const $ = cheerio.load(shopresponse.data);
|
||||
const shopname = $('title').text();
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: api_link,
|
||||
|
|
@ -25,7 +30,7 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${id} 商铺上新`,
|
||||
title: `${shopname || id} 商铺上新`,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue