wangkun hace 2 años
padre
commit
7362f9582c

BIN
weixinzhishu/.DS_Store


BIN
weixinzhishu/logs/.DS_Store


+ 10 - 15
weixinzhishu/weixinzhishu_hot_search/weixinzhishu_hot_search.py

@@ -34,8 +34,7 @@ class HotSearch:
                 source = "百度"
                 title = title_html.xpath("./text()")[0].strip()
                 publish_time = cls.today
-                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time)
-                values("{source}", '{title}', "{publish_time}")"""
+                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time) values("{source}", '{title}', "{publish_time}")"""
                 Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
                 MysqlHelper.update_values(log_type, crawler, insert_sql, env, action="")
                 Common.logger(log_type, crawler).info("写入数据库成功\n")
@@ -70,8 +69,7 @@ class HotSearch:
 
                 title = tr.xpath("./td[2]/*[1]/text()")[0].strip()
 
-                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time)
-                                values("{source}", '{title}', "{publish_time}")"""
+                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time) values("{source}", '{title}', "{publish_time}")"""
                 Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
                 MysqlHelper.update_values(log_type, crawler, insert_sql, env, action="")
                 Common.logger(log_type, crawler).info("写入数据库成功\n")
@@ -110,8 +108,7 @@ class HotSearch:
                 # print(title)
                 # print('\n')
 
-                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time)
-                                values("{source}", '{title}', "{publish_time}")"""
+                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time) values("{source}", '{title}', "{publish_time}")"""
                 Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
                 MysqlHelper.update_values(log_type, crawler, insert_sql, env, action="")
                 Common.logger(log_type, crawler).info("写入数据库成功\n")
@@ -149,8 +146,7 @@ class HotSearch:
                 # print(publish_time)
                 # print(title)
 
-                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time)
-                                values("{source}", '{title}', "{publish_time}")"""
+                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time) values("{source}", '{title}', "{publish_time}")"""
                 Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
                 MysqlHelper.update_values(log_type, crawler, insert_sql, env, action="")
                 Common.logger(log_type, crawler).info("写入数据库成功\n")
@@ -188,8 +184,7 @@ class HotSearch:
                 # print(publish_time)
                 # print(title)
 
-                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time)
-                                values("{source}", '{title}', "{publish_time}")"""
+                insert_sql = f"""insert into crawler_hot_title(source, title, publish_time) values("{source}", '{title}', "{publish_time}")"""
                 Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
                 MysqlHelper.update_values(log_type, crawler, insert_sql, env, action="")
                 Common.logger(log_type, crawler).info("写入数据库成功\n")
@@ -198,9 +193,9 @@ class HotSearch:
 
 
 if __name__ == "__main__":
-    # HotSearch.baidu_hot_search("hot-search-baidu", "weixinzhishu", "dev")
-    # HotSearch.douyin_hot_search("hot-search-douyin", "weixinzhishu", "dev")
-    # HotSearch.kuaishou_hot_search("hot-search-kuaishou", "weixinzhishu", "dev")
-    # HotSearch.weibo_hot_search("hot-search-weibo", "weixinzhishu", "dev")
-    HotSearch.weixin_hot_search("hot-search-weixin", "weixinzhishu", "dev")
+    HotSearch.baidu_hot_search("hot-search", "weixinzhishu", "dev")
+    HotSearch.douyin_hot_search("hot-search", "weixinzhishu", "dev")
+    HotSearch.kuaishou_hot_search("hot-search", "weixinzhishu", "dev")
+    HotSearch.weibo_hot_search("hot-search", "weixinzhishu", "dev")
+    HotSearch.weixin_hot_search("hot-search", "weixinzhishu", "dev")
 

+ 15 - 10
weixinzhishu/weixinzhishu_main/run_weixinzhishu_hot_search.py

@@ -12,37 +12,42 @@ from weixinzhishu.weixinzhishu_hot_search.weixinzhishu_hot_search import HotSear
 class Main:
     @classmethod
     def thread_baidu(cls, log_type, crawler, env):
-        Common.logger(log_type, crawler).info(f'开始抓取"百度热搜榜"')
+        # 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'开始抓取"快手热搜榜"')
+        # 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'开始抓取"抖音热搜榜"')
+        # 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'开始抓取"微信热搜榜"')
+        # 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'开始抓取"微博热搜榜"')
+        # 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(f"开始抓取今日热搜榜\n")
-        thread_baidu = Thread(target=cls.thread_baidu, args=("hot-search-baidu", crawler, env))
-        thread_kuaishou = Thread(target=cls.thread_kuaishou, args=("hot-search-kuaishou", crawler, env))
-        thread_douyin = Thread(target=cls.thread_douyin, args=("hot-search-douyin", crawler, env))
-        thread_weixin = Thread(target=cls.thread_weixin, args=("hot-search-weixin", crawler, env))
-        thread_weibo = Thread(target=cls.thread_weibo, args=("hot-search-weibo", crawler, env))
+        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()