| 123456789101112131415161718192021222324252627282930 |
- # -*- coding: utf-8 -*-
- # Author : Charley
- # Python : 3.10.8
- # Date : 2025/10/22 11:30
- import time
- import schedule
- import subprocess
- def run_spider():
- """执行爬虫脚本"""
- try:
- result = subprocess.run(['python', 'jhs_app_spider.py'], check=True)
- print(f"爬虫执行成功,返回码: {result.returncode}")
- except subprocess.CalledProcessError as e:
- print(f"爬虫执行失败: {e}")
- def schedule_task():
- """设置定时任务"""
- run_spider()
- schedule.every().day.at("04:30").do(run_spider)
- while True:
- schedule.run_pending()
- time.sleep(1)
- if __name__ == "__main__":
- schedule_task()
|