renyupeng 1 year ago
parent
commit
a215773a4a

File diff suppressed because it is too large
+ 72 - 0
DouyinSpider/SpiderDouyinHeader.py


+ 59 - 48
utils/PromoterInfoWebHook.py

@@ -9,6 +9,8 @@ coding=utf-8
 @Tel 1501435553
 """
 from flask import Flask, request, json
+
+from DouyinSpider.SpiderDouyinHeader import SpiderDouyinHeader
 from constant.ConfConstant import ConfConstant
 from spider.PromoterFansInfo import PromoterFansInfo
 from spider.PromoterInfoSpider import PromoterInfoSpider
@@ -19,6 +21,8 @@ from multiprocessing import Process
 
 from spider.ReturnPromoterInfoSpider import ReturnPromoterInfoSpider
 from utils.cookie_update import cookie_update
+from utils.douyin_cookie_update import douyin_cookie_update
+
 from utils.send_feishu_msg import SendFeiShuMsg
 
 app = Flask(__name__)
@@ -32,63 +36,70 @@ def api_root():
 def webhook_get_promoter():
     rep = json.loads(request.data)
     promoterId = rep["promoterId"]
+    if rep["mediaId"] == 2:
+        cookie = cookie_update.get_cookie_handler()[0]
+        phone_num = cookie_update.get_cookie_handler()[1]
+        roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
 
-    cookie = cookie_update.get_cookie_handler()[0]
-    phone_num = cookie_update.get_cookie_handler()[1]
-    roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
+        if json.loads(roll).__contains__("result"):
+            if json.loads(roll)["result"] == 100110000:
+                SendFeiShuMsg.send_cookie_robot_msg("cookie 永久失效 轻更新cookie 唯一电话为{phone_num}".format(phone_num=phone_num))
+                cookie_update.update_cookie_handler(phone_num)
+                retry_cookie = cookie_update.get_cookie_handler()[0]
+                rollback = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
+                p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
+                p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, retry_cookie))
+                p3 = Process(target=PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander, args=(promoterId, retry_cookie))
+                p4 = Process(target=PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler,
+                             args=(promoterId, retry_cookie))
+                p5 = Process(target=PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler,
+                             args=(promoterId, retry_cookie))
+                p1.start()
+                p2.start()
+                p3.start()
+                p4.start()
+                p5.start()
+                return rollback
 
-    if json.loads(roll).__contains__("result"):
-        if json.loads(roll)["result"] == 100110000:
-            SendFeiShuMsg.send_cookie_robot_msg("cookie 永久失效 轻更新cookie 唯一电话为{phone_num}".format(phone_num=phone_num))
-            cookie_update.update_cookie_handler(phone_num)
-            retry_cookie = cookie_update.get_cookie_handler()[0]
-            rollback = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
-            p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
-            p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, retry_cookie))
-            p3 = Process(target=PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander, args=(promoterId, retry_cookie))
-            p4 = Process(target=PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler,
-                         args=(promoterId, retry_cookie))
-            p5 = Process(target=PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler,
-                         args=(promoterId, retry_cookie))
-            p1.start()
-            p2.start()
-            p3.start()
-            p4.start()
-            p5.start()
-            return rollback
+            else:
+                SendFeiShuMsg.send_cookie_robot_msg(
+                    "cookie 临时失效 唯一电话为{phone_num},临时失效code{code}".format(phone_num=phone_num,
+                                                                         code=json.loads(roll)["result"]))
+                cookie_update.update_temporary_cookie_handler(phone_num)
+                retry_cookie = cookie_update.get_cookie_handler()[0]
+                rolls = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
+                p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
+                p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, retry_cookie))
+                p3 = Process(target=PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander, args=(promoterId, retry_cookie))
+                p4 = Process(target=PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler,
+                             args=(promoterId, retry_cookie))
+                p5 = Process(target=PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler,
+                             args=(promoterId, retry_cookie))
+                p1.start()
+                p2.start()
+                p3.start()
+                p4.start()
+                p5.start()
+                return rolls
 
         else:
-            SendFeiShuMsg.send_cookie_robot_msg(
-                "cookie 临时失效 唯一电话为{phone_num},临时失效code{code}".format(phone_num=phone_num,
-                                                                     code=json.loads(roll)["result"]))
-            cookie_update.update_temporary_cookie_handler(phone_num)
-            retry_cookie = cookie_update.get_cookie_handler()[0]
-            rolls = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
-            p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
-            p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, retry_cookie))
-            p3 = Process(target=PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander, args=(promoterId, retry_cookie))
-            p4 = Process(target=PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler,
-                         args=(promoterId, retry_cookie))
-            p5 = Process(target=PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler,
-                         args=(promoterId, retry_cookie))
+            p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, cookie))
+            p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, cookie))
+            p3 = Process(target=PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander, args=(promoterId, cookie))
+            p4 = Process(target=PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler, args=(promoterId, cookie))
+            p5 = Process(target=PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler, args=(promoterId, cookie))
             p1.start()
             p2.start()
             p3.start()
             p4.start()
             p5.start()
-            return rolls
-
+            return roll
     else:
-        p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, cookie))
-        p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, cookie))
-        p3 = Process(target=PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander, args=(promoterId, cookie))
-        p4 = Process(target=PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler, args=(promoterId, cookie))
-        p5 = Process(target=PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler, args=(promoterId, cookie))
-        p1.start()
-        p2.start()
-        p3.start()
-        p4.start()
-        p5.start()
+        rep = json.loads(request.data)
+        promoterId = rep["promoterId"]
+        cookie = douyin_cookie_update.get_cookie_handler()[0]
+        roll = SpiderDouyinHeader().DouyinHandler(promoterId, cookie)
+        print(roll,'------------------')
         return roll
 
 
@@ -102,4 +113,4 @@ def webhook_update_promoter():
 
 
 if __name__ == '__main__':
-    app.run(port=9999, host=ConfConstant.URL, debug=True)
+    app.run(port=9999, host='127.0.0.1', debug=True)

+ 1 - 0
utils/cookie_update.py

@@ -15,6 +15,7 @@ class cookie_update:
     def get_cookie_handler():
         sql = "select cookie ,phone_num from kwai_promoter.kuaishou_supply_chain_cookie where status =0"
         result = MysqlUtils().QueryOne(sql)
+        print(result)
         return result
 
     @staticmethod

+ 29 - 0
utils/douyin_cookie_update.py

@@ -0,0 +1,29 @@
+# Author renyupeng
+# coding=utf-8
+# @Time    : 2023/2/27 2:16 下午
+# @Site    : 
+# @File    : cookie_update.py
+# @Software: PyCharm
+# @contact: renyupeng@c-top.com.cn
+# @Tel 1501435553
+from utils.mysql_utils import MysqlUtils
+
+
+class douyin_cookie_update:
+
+    @staticmethod
+    def get_cookie_handler():
+        sql = "select cookie ,phone_num from kwai_promoter.douyin_supply_chain_cookie where status =0"
+        result = MysqlUtils().QueryOne(sql)
+        print(result)
+        return result
+
+    @staticmethod
+    def update_cookie_handler(phone_num):
+        sql = "update kwai_promoter.douyin_supply_chain_cookie set status=1 where phone_num={phone_num}".format(
+            phone_num=phone_num)
+        MysqlUtils().Operate(sql=sql, params=None, DML=True)
+
+
+if __name__ == '__main__':
+    douyin_cookie_update().get_cookie_handler()