mirror of
https://github.com/zhangxiangliang/stock-api.git
synced 2025-01-23 06:00:24 +08:00
fix: 修复 雪球类型和网易类型搜索股票代码未 URL 编码
This commit is contained in:
parent
347b508917
commit
67914d5cdf
@ -74,7 +74,7 @@ const Netease: StockApi = {
|
||||
*/
|
||||
async searchStocks(key: string): Promise<Stock[]> {
|
||||
// 数据获取
|
||||
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);
|
||||
|
||||
// 解析数据
|
||||
|
@ -93,7 +93,7 @@ const Xueqiu: StockApi & { getToken(): Promise<string> } = {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user