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:
parent
1d6a70a152
commit
840cfebc4e
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue