ReMe/experiencemaker/utils/util_function.py
2025-06-11 23:13:46 +08:00

23 lines
551 B
Python

import json
import os
import re
from loguru import logger
def get_html_match_content(content: str, key: str):
pattern = rf"<{key}>(.*?)</{key}>"
match = re.search(pattern, content, re.DOTALL)
if match:
return match.group(1)
return None
def load_env_keys(file_path: str = ".env"):
if os.path.exists(file_path):
with open(file_path) as f:
config = json.load(f)
for k, v in config.items():
os.environ[k] = v
else:
logger.warning(f"{file_path} file not found~")