utils.py 720 B

123456789101112131415161718192021222324252627
  1. # utils.py
  2. from pathlib import Path
  3. from typing import List
  4. import logging
  5. # 把 1step.py 的主逻辑封装成函数
  6. from step1 import main as step1_main
  7. from step2 import main as step2_main
  8. log = logging.getLogger("utils")
  9. async def run_step1(proxy: str | None = None) -> str:
  10. try:
  11. await step1_main(proxy)
  12. return "画廊链接抓取完成!"
  13. except Exception as e:
  14. log.exception("step1 执行失败")
  15. return f"抓取失败:{e}"
  16. async def run_step2(proxy: str | None = None) -> str:
  17. try:
  18. await step2_main(proxy)
  19. return "图片下载完成!"
  20. except Exception as e:
  21. log.exception("step2 执行失败")
  22. return f"下载失败:{e}"