diff --git a/src/stocks/netease/index.ts b/src/stocks/netease/index.ts index 35f9ee6..3e028fc 100644 --- a/src/stocks/netease/index.ts +++ b/src/stocks/netease/index.ts @@ -74,7 +74,7 @@ const Netease: StockApi = { */ async searchStocks(key: string): Promise { // 数据获取 - const url = `https://quotes.money.163.com/stocksearch/json.do?type=&count=5&word=${key}&callback=topstock`; + const url = `https://quotes.money.163.com/stocksearch/json.do?type=&count=5&word=${encodeURIComponent(key)}&callback=topstock`; const res = await fetch.get(url); // 解析数据 diff --git a/src/stocks/xueqiu/index.ts b/src/stocks/xueqiu/index.ts index e3ef868..b2cb0b5 100644 --- a/src/stocks/xueqiu/index.ts +++ b/src/stocks/xueqiu/index.ts @@ -93,7 +93,7 @@ const Xueqiu: StockApi & { getToken(): Promise } = { const token = await this.getToken(); // 数据获取 - const url = `https://xueqiu.com/stock/search.json?code=${key}`; + const url = `https://xueqiu.com/stock/search.json?code=${encodeURIComponent(key)}`; const res = await fetch.get(url).set('Cookie', token); const body = JSON.parse(res.text);