mirror of
https://github.com/zhangxiangliang/stock-api.git
synced 2025-01-23 06:00:24 +08:00
fix: 修复 腾讯股票代码接口编码错误
This commit is contained in:
parent
f17a9bc71e
commit
23603be65c
@ -5,6 +5,7 @@ import TencentExchangeTransform from "@stocks/tencent/transforms/exchange";
|
||||
|
||||
// Utils
|
||||
import fetch from "@utils/fetch";
|
||||
import iconv from "@utils/iconv";
|
||||
|
||||
// Types
|
||||
import Stock from "types/stock";
|
||||
@ -29,9 +30,9 @@ class Tencent extends Base {
|
||||
|
||||
// 数据获取
|
||||
const url = `https://qt.gtimg.cn/q=${transform}`;
|
||||
const res = await fetch.get(url);
|
||||
const res = await fetch.get(url).responseType('blob');
|
||||
|
||||
const body = res.text;
|
||||
const body = iconv.decode(res.body, "gbk");
|
||||
const rows = body.split(";\n");
|
||||
const row = rows[0];
|
||||
|
||||
@ -52,9 +53,9 @@ class Tencent extends Base {
|
||||
|
||||
// 数据获取
|
||||
const url = `https://qt.gtimg.cn/q=${transforms.join(',')}`;
|
||||
const res = await fetch.get(url);
|
||||
const res = await fetch.get(url).responseType('blob');
|
||||
|
||||
const body = res.text;
|
||||
const body = iconv.decode(res.body, "gbk");
|
||||
const rows = body.split(";\n");
|
||||
|
||||
return codes.map((code, index) => {
|
||||
|
Loading…
Reference in New Issue
Block a user