Merge branch 'main' of https://git.jb18cm.plus/fanfpy/AssetManager.API
This commit is contained in:
commit
fd3282881b
@ -1,6 +1,7 @@
|
|||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using AssetManager.Data;
|
using AssetManager.Data;
|
||||||
using AssetManager.Models.DTOs;
|
using AssetManager.Models.DTOs;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -49,9 +50,13 @@ public class MarketDataService : IMarketDataService
|
|||||||
{
|
{
|
||||||
_logger.LogInformation($"Requesting stock price for symbol: {symbol} (腾讯财经接口)");
|
_logger.LogInformation($"Requesting stock price for symbol: {symbol} (腾讯财经接口)");
|
||||||
|
|
||||||
|
// 注册GBK编码支持
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
|
||||||
// 腾讯财经美股接口:前缀us,大写代码
|
// 腾讯财经美股接口:前缀us,大写代码
|
||||||
var url = $"http://qt.gtimg.cn/q=us{symbol.ToUpper()}";
|
var url = $"http://qt.gtimg.cn/q=us{symbol.ToUpper()}";
|
||||||
var response = await _httpClient.GetStringAsync(url);
|
var responseBytes = await _httpClient.GetByteArrayAsync(url);
|
||||||
|
var response = Encoding.GetEncoding("GBK").GetString(responseBytes);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(response) || !response.Contains("~"))
|
if (string.IsNullOrEmpty(response) || !response.Contains("~"))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user