From 1b67e209322743cf42e28f0ad64ccd96ff7b5231 Mon Sep 17 00:00:00 2001 From: ArvinLovegood Date: Tue, 20 May 2025 10:46:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor(backend/data):=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=B4=A2=E8=81=94=E7=A4=BE=E7=94=B5=E6=8A=A5=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 market_news_api.go 中的 GoQuery 选择器,从 ".telegraph-list"改为 ".telegraph-content-box"- 更新 openai_api_test.go 中的 TestGetTopNewsList 函数,增加测试日志输出 --- backend/data/market_news_api.go | 2 +- backend/data/openai_api_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/data/market_news_api.go b/backend/data/market_news_api.go index 015101c..172fbbc 100644 --- a/backend/data/market_news_api.go +++ b/backend/data/market_news_api.go @@ -37,7 +37,7 @@ func (m MarketNewsApi) GetNewTelegraph(crawlTimeOut int64) *[]models.Telegraph { //logger.SugaredLogger.Info(string(response.Body())) document, _ := goquery.NewDocumentFromReader(strings.NewReader(string(response.Body()))) - document.Find(".telegraph-list").Each(func(i int, selection *goquery.Selection) { + document.Find(".telegraph-content-box").Each(func(i int, selection *goquery.Selection) { //logger.SugaredLogger.Info(selection.Text()) telegraph := models.Telegraph{Source: "财联社电报"} spans := selection.Find("div.telegraph-content-box span") diff --git a/backend/data/openai_api_test.go b/backend/data/openai_api_test.go index 057dcad..046ca8e 100644 --- a/backend/data/openai_api_test.go +++ b/backend/data/openai_api_test.go @@ -19,7 +19,8 @@ func TestNewDeepSeekOpenAiConfig(t *testing.T) { } func TestGetTopNewsList(t *testing.T) { - GetTopNewsList(30) + news := GetTopNewsList(30) + t.Log(news) } func TestSearchGuShiTongStockInfo(t *testing.T) {