1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- # -*- coding: utf-8 -*-
- # @Author: wangkun
- # @Time: 2022/4/25
- import datetime
- import os
- import random
- import sys
- import time
- sys.path.append(os.getcwd())
- from main.common import Common
- from main.download import BSZF
- class Main:
- @classmethod
- def download_job_dev(cls):
- """
- 测试环境脚本
- """
- Common.crawler_log().info("开始抓取本山祝福视频\n")
- BSZF.get_recommend()
- BSZF.download_video("dev")
- # 删除多余日志
- Common.del_logs()
- # 统计累计下载数量
- Common.benshanzhufu_download_count()
- @classmethod
- def download_job_prod(cls):
- """
- 正式环境脚本
- """
- while True:
- prod_time = datetime.datetime.now()
- if prod_time.hour < 15 or prod_time.hour > 19:
- Common.crawler_log().info("结束抓取视频\n")
- time.sleep(3)
- break
- else:
- BSZF.get_recommend()
- BSZF.download_video("prod")
- time.sleep(random.randint(1, 3))
- # 删除多余日志
- Common.del_logs()
- # 统计累计下载数量
- Common.benshanzhufu_download_count()
- @classmethod
- def main(cls):
- while True:
- while True:
- main_time = datetime.datetime.now()
- if 19 >= main_time.hour >= 15:
- Common.crawler_log().info("开始抓取本山祝福视频\n")
- cls.download_job_prod()
- else:
- time.sleep(600)
- break
- if __name__ == "__main__":
- main = Main()
- main.main()
|