fix(scripts): 升级热搜词抓取引擎,适配 v3.5.0 大洲战区多层级解析

This commit is contained in:
hotyue
2026-04-15 04:25:25 +00:00
parent 8016b0531c
commit 7321b76bb5
+5 -3
View File
@@ -21,13 +21,15 @@ HEADERS = {
} }
def get_active_regions(): def get_active_regions():
"""动态提取 map.json 中的战区 (修正:精准穿透 JSON 数组结构)""" """动态提取 map.json 中的战区 (适配 v3.5.0 大洲战区降维架构)"""
try: try:
with open(MAP_JSON_PATH, 'r', encoding='utf-8') as f: with open(MAP_JSON_PATH, 'r', encoding='utf-8') as f:
data = json.load(f) data = json.load(f)
# 穿透到 countries 列表,提取所有的国家代码 (id)
regions = [] regions = []
for country in data.get('countries', []): # 第一层穿透:遍历所有大洲战区 (continents)
for continent in data.get('continents', []):
# 第二层穿透:遍历大洲下的所有国家 (countries)
for country in continent.get('countries', []):
if 'id' in country: if 'id' in country:
regions.append(country['id']) regions.append(country['id'])
return regions return regions