Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(route): xueqiu snb.js #10281

Merged
merged 2 commits into from Jul 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/v2/xueqiu/snb.js
Expand Up @@ -8,12 +8,15 @@ module.exports = async (ctx) => {
const response = await got({
method: 'get',
url,
headers: {
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36 Edg/103.0.1264.37"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const UA = require('@/utils/rand-user-agent')({ browser: 'chrome', os: 'android', device: 'mobile' });
Suggested change
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36 Edg/103.0.1264.37"
"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