Skip to content

Commit

Permalink
feat: 更换搜索接口为腾讯自选股wap
Browse files Browse the repository at this point in the history
  • Loading branch information
enzheng128 committed Oct 12, 2024
1 parent 0dcd520 commit 19a8c1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/explorer/stockService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ export default class StockService extends LeekService {
stocks.forEach((item: any) => {
const { code, name, market } = item;
const _code = `${market}${code}`;
if (['sz', 'sh'].includes(market)) {
if (['sz', 'sh', 'bj'].includes(market)) {
result.push({
label: `${_code} | ${name}`,
description: `A股`,
Expand Down
15 changes: 5 additions & 10 deletions src/shared/tencentStock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@ import Axios from 'axios';
import Log from './log';
import { decode } from 'iconv-lite';

const searchUrl = 'https://proxy.finance.qq.com/smartboxgtimg/s3/index.php';
const searchUrl = 'https://proxy.finance.qq.com/ifzqgtimg/appstock/smartbox/search/get';
const stockDataUrl = 'https://qt.gtimg.cn/q=';
export const searchStockList = async (keyword: string) => {
Log.info('searchStockList keyword: ', keyword);
const stockResponse = await Axios.get(searchUrl, {
params: {
v: 2,
q: keyword,
t: 'all',
},
});
Log.info('stockResponse: ', stockResponse.data);
const stockListStr = unescape(
(stockResponse.data || '').replace('v_hint="', '').replace(/"$/, '').replace(/\\u/g, '%u')
);
Log.info('stockListStr: ', stockListStr, keyword);
const stockList = stockListStr.split('^').map((stockItemStr: string) => {
const stockItemArr = stockItemStr.split('~');
const stockListArray = stockResponse?.data?.data?.stock || [];
Log.info('stockListStr: ', stockListArray, keyword);
const stockList = stockListArray.map((stockItemArr: string[]) => {
return {
code: stockItemArr[1],
code: stockItemArr[1].toLowerCase(),
name: stockItemArr[2],
market: stockItemArr[0],
abbreviation: stockItemArr[3],
Expand Down

0 comments on commit 19a8c1d

Please sign in to comment.