# -*- coding: utf-8 -*- # @Author: wangkun # @Time: 2023/3/31 import os import sys from threading import Thread sys.path.append(os.getcwd()) from common.common import Common from weixinzhishu.weixinzhishu_hot_search.weixinzhishu_hot_search import HotSearch class Main: @classmethod def thread_baidu(cls, log_type, crawler, env): # Common.logger(log_type, crawler).info(f'开始抓取"百度热搜榜"') HotSearch.baidu_hot_search(log_type, crawler, env) # Common.logger(log_type, crawler).info(f'"百度热搜榜"抓取完毕\n') @classmethod def thread_kuaishou(cls, log_type, crawler, env): # Common.logger(log_type, crawler).info(f'开始抓取"快手热搜榜"') HotSearch.kuaishou_hot_search(log_type, crawler, env) # Common.logger(log_type, crawler).info(f'"快手热搜榜"抓取完毕\n') @classmethod def thread_douyin(cls, log_type, crawler, env): # Common.logger(log_type, crawler).info(f'开始抓取"抖音热搜榜"') HotSearch.douyin_hot_search(log_type, crawler, env) # Common.logger(log_type, crawler).info(f'"快手热搜榜"抓取完毕\n') @classmethod def thread_weixin(cls, log_type, crawler, env): # Common.logger(log_type, crawler).info(f'开始抓取"微信热搜榜"') HotSearch.weixin_hot_search(log_type, crawler, env) # Common.logger(log_type, crawler).info(f'"微信热搜榜"抓取完毕\n') @classmethod def thread_weibo(cls, log_type, crawler, env): # Common.logger(log_type, crawler).info(f'开始抓取"微博热搜榜"') HotSearch.weibo_hot_search(log_type, crawler, env) # Common.logger(log_type, crawler).info(f'"微博热搜榜"抓取完毕\n') @classmethod def thread_main(cls, log_type, crawler, env): Common.logger(log_type, crawler).info("开始抓取今日热搜榜\n") thread_baidu = Thread(target=cls.thread_baidu, args=(log_type, crawler, env)) thread_kuaishou = Thread(target=cls.thread_kuaishou, args=(log_type, crawler, env)) thread_douyin = Thread(target=cls.thread_douyin, args=(log_type, crawler, env)) thread_weixin = Thread(target=cls.thread_weixin, args=(log_type, crawler, env)) thread_weibo = Thread(target=cls.thread_weibo, args=(log_type, crawler, env)) thread_baidu.start() thread_kuaishou.start() thread_douyin.start() thread_weixin.start() thread_weibo.start() thread_baidu.join() thread_kuaishou.join() thread_douyin.join() thread_weixin.join() thread_weibo.join() Common.logger(log_type, crawler).info("今日热搜榜全部抓取完毕\n") if __name__ == "__main__": Main.thread_main("hot-search", "weixinzhishu", "prod") pass