fix(route): xueqiu snb.js (#10281)

* Update snb.js

* fix: use random ua

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
大象鼻子长又长 2022-07-31 04:24:56 +08:00 committed by GitHub
parent 1d6a70a152
commit 840cfebc4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -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;