diff --git a/lib/v2/xueqiu/snb.js b/lib/v2/xueqiu/snb.js index d75f98d07..c3cec12ea 100644 --- a/lib/v2/xueqiu/snb.js +++ b/lib/v2/xueqiu/snb.js @@ -1,19 +1,21 @@ const got = require('@/utils/got'); const { parseDate } = require('@/utils/parse-date'); +const UA = require('@/utils/rand-user-agent')({ browser: 'chrome', os: 'android', device: 'mobile' }); module.exports = async (ctx) => { const id = ctx.params.id; const url = 'https://xueqiu.com/p/' + id; - const response = await got({ - method: 'get', - url, + const response = await got(url, { + headers: { + 'User-Agent': UA, + }, }); const data = response.data; - const pattern = /SNB.cubeInfo = (.+?);/; - const info = pattern.exec(data)[1]; - const obj = JSON.parse(info); + const pattern = /SNB.cubeInfo = {(.+)}/; + const info = pattern.exec(data); + const obj = JSON.parse('{' + info[1] + '}'); const rebalancing_histories = obj.sell_rebalancing.rebalancing_histories; const snb_title = obj.name + ' 的调仓历史'; const snb_description = obj.description;