Skip to content

Commit

Permalink
fix(route): xueqiu snb.js (#10281)
Browse files Browse the repository at this point in the history
* Update snb.js

* fix: use random ua

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
  • Loading branch information
lzq2357 and TonyRL committed Jul 30, 2022
1 parent 1d6a70a commit 840cfeb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions 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;
Expand Down

0 comments on commit 840cfeb

Please sign in to comment.