html逻辑优化
This commit is contained in:
@@ -8,6 +8,7 @@ BOM 成本 - 终极树状结构抓取脚本 (全站 1400+ 父件及 5 层嵌套
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import subprocess
|
||||
import random
|
||||
from pathlib import Path
|
||||
|
||||
@@ -219,6 +220,21 @@ def fetch_bom_cost_tree():
|
||||
log("INFO", f"💾 进度已实时保存至 JSON ({index+1}/{len(clean_parents_list)})")
|
||||
|
||||
log("OK", f"=== 🏆 终极 BOM 成本多层树状抓取完成!文件路径: {TREE_FILE_PATH} ===")
|
||||
|
||||
# 抓取完成后,自动调用入库脚本将 JSON 导入 SQLite
|
||||
log("INFO", "⏳ 正在自动将 JSON 数据同步至 SQLite 数据库...")
|
||||
try:
|
||||
import_script = Path(__file__).parent / "import_to_sqlite.py"
|
||||
# 使用 sys.executable 确保使用当前的 Python 环境
|
||||
import sys
|
||||
result = subprocess.run([sys.executable, str(import_script), "--bom-only"], capture_output=True, text=True)
|
||||
if result.returncode == 0:
|
||||
log("OK", "✅ 数据库同步成功!")
|
||||
print(result.stdout)
|
||||
else:
|
||||
log("ERR", f"❌ 数据库同步失败: {result.stderr}")
|
||||
except Exception as db_err:
|
||||
log("ERR", f"❌ 自动触发入库脚本失败: {db_err}")
|
||||
|
||||
except Exception as e:
|
||||
log("ERR", f"发生异常: {e}")
|
||||
|
||||
Reference in New Issue
Block a user