From 23603be65c464de815ecb96783adfc2251824f04 Mon Sep 17 00:00:00 2001 From: zhangxiangliang Date: Mon, 3 Aug 2020 02:36:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20=E8=85=BE=E8=AE=AF?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E4=BB=A3=E7=A0=81=E6=8E=A5=E5=8F=A3=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stocks/tencent/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stocks/tencent/index.ts b/src/stocks/tencent/index.ts index 2bb1d0f..1d264ee 100644 --- a/src/stocks/tencent/index.ts +++ b/src/stocks/tencent/index.ts @@ -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) => {