Skip to content

Commit e547513

Browse files
committed
feat: 添加OpenAI官网价格抓取功能
新增OpenAI价格数据抓取模块,包括HTML解析和数据库存储逻辑 在cron任务中集成OpenAI价格更新,与现有价格更新任务协同执行
1 parent 11f06ca commit e547513

File tree

3 files changed

+444
-0
lines changed

3 files changed

+444
-0
lines changed

backend/cron/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/robfig/cron/v3"
88

9+
openai_api "aimodels-prices/cron/openai-api"
910
openrouter_api "aimodels-prices/cron/openrouter-api"
1011
price_audit "aimodels-prices/cron/price-audit"
1112
siliconflow_api "aimodels-prices/cron/siliconflow-api"
@@ -38,6 +39,12 @@ func Init() {
3839
if err := siliconflow_api.UpdateSiliconFlowPrices(); err != nil {
3940
log.Printf("SiliconFlow价格更新任务执行失败: %v", err)
4041
}
42+
43+
time.Sleep(3 * time.Second)
44+
45+
if err := openai_api.FetchAndSavePrices(); err != nil {
46+
log.Printf("OpenAI官网价格获取任务执行失败: %v", err)
47+
}
4148
})
4249

4350
if err != nil {
@@ -82,6 +89,13 @@ func Init() {
8289
if err := siliconflow_api.UpdateSiliconFlowPrices(); err != nil {
8390
log.Printf("初始SiliconFlow价格更新任务执行失败: %v", err)
8491
}
92+
93+
// 等待几秒后执行OpenAI官网价格获取任务
94+
time.Sleep(3 * time.Second)
95+
log.Println("立即执行OpenAI官网价格获取任务...")
96+
if err := openai_api.FetchAndSavePrices(); err != nil {
97+
log.Printf("初始OpenAI官网价格获取任务执行失败: %v", err)
98+
}
8599
}()
86100
}
87101

0 commit comments

Comments
 (0)