chore: 暂存本地修改

This commit is contained in:
hello-dd-code
2026-04-28 17:33:51 +08:00
parent ba04fe42fc
commit f67cb30f0d
15 changed files with 1139 additions and 97 deletions
+9 -3
View File
@@ -23,6 +23,7 @@ if project_root not in sys.path:
sys.path.append(project_root)
from Db import Db # 你的 DB 封装
import config as project_config
# logging 配置
logging.basicConfig(
@@ -45,9 +46,14 @@ class GaodeSpider:
sleep_between_cities: float = 3.0,
):
self.db = db_connection
self.api_key = (api_key or os.environ.get("AMAP_API_KEY", "")).strip()
config_api_key = ""
gaode_config = getattr(project_config, "GAODE_CONFIG", None)
if isinstance(gaode_config, dict):
config_api_key = str(gaode_config.get("API_KEY", "")).strip()
self.api_key = (api_key or os.environ.get("AMAP_API_KEY", "") or config_api_key).strip()
if not self.api_key:
raise ValueError("AMAP_API_KEY environment variable is required")
raise ValueError("高德 API Key 未配置,请在 config.py 的 GAODE_CONFIG.API_KEY 或环境变量 AMAP_API_KEY 中填写")
self.api_base = "https://restapi.amap.com/v3/place/text"
self.offset = offset
self.session = self._build_session()
@@ -369,7 +375,7 @@ class GaodeSpider:
return
total_stored = 0
keywords_suffix = ""
keywords_suffix = ""
for city_id, city_info in self.cities.items():
try: