renyupeng 11 months ago
parent
commit
a59429bcc1

File diff suppressed because it is too large
+ 5 - 0
spider/PromoterInfoSpider.py


+ 4 - 0
spider/PromoterVideoAnalysisInfo.py

@@ -12,6 +12,7 @@ import json
 
 
 import requests
 import requests
 
 
+from utils.cookie_update import cookie_update
 from utils.mysql_helper import insert
 from utils.mysql_helper import insert
 from utils.mysql_utils import MysqlUtils
 from utils.mysql_utils import MysqlUtils
 from utils.send_feishu_msg import SendFeiShuMsg
 from utils.send_feishu_msg import SendFeiShuMsg
@@ -32,6 +33,7 @@ class PromoterVideoAnalysisInfo:
                       "/promoter/video/analysis/key/indicator?promoterId={promoterId}&timeRangeType={timeRangeType}" \
                       "/promoter/video/analysis/key/indicator?promoterId={promoterId}&timeRangeType={timeRangeType}" \
                     .format(timeRangeType=i, promoterId=promoterId)
                     .format(timeRangeType=i, promoterId=promoterId)
                 rep = requests.get(url=url, headers=headers)
                 rep = requests.get(url=url, headers=headers)
+                print(rep.text,'--------------')
                 table_name = 'kwai_promoter_video_info'
                 table_name = 'kwai_promoter_video_info'
                 data = json.loads(rep.text)["data"]
                 data = json.loads(rep.text)["data"]
                 promoter_video_item = {"commentCount": data["commentCount"], "likeCount": data["likeCount"],
                 promoter_video_item = {"commentCount": data["commentCount"], "likeCount": data["likeCount"],
@@ -45,3 +47,5 @@ class PromoterVideoAnalysisInfo:
         except Exception as e:
         except Exception as e:
             SendFeiShuMsg.send_robot_msg(
             SendFeiShuMsg.send_robot_msg(
                 'PromoterVideoAnalysisInfo  {promoterId}请求错误请检查cookie{e}'.format(promoterId=promoterId, e=e))
                 'PromoterVideoAnalysisInfo  {promoterId}请求错误请检查cookie{e}'.format(promoterId=promoterId, e=e))
+
+

File diff suppressed because it is too large
+ 2 - 6
spider/ReturnPromoterInfoSpider.py


+ 2 - 1
spider/SpiderPromoterHeader.py

@@ -34,7 +34,8 @@ class SpiderPromoterHeader:
         else:
         else:
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_item = random.choice(random_member)
             random_item = random.choice(random_member)
-            cookie = random_item[0].decode('utf-8')
+            # cookie = random_item[0].decode('utf-8')
+            cookie = cookie_update.get_cookie_handler()
             phone_num = int(random_item[1])
             phone_num = int(random_item[1])
 
 
             headers = {'User-Agent': 'Mozilla/5.0',
             headers = {'User-Agent': 'Mozilla/5.0',

+ 2 - 1
spider/SpiderPromoterHeaderMgs.py

@@ -34,7 +34,8 @@ class SpiderPromoterHeader:
         else:
         else:
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_item = random.choice(random_member)
             random_item = random.choice(random_member)
-            cookie = random_item[0].decode('utf-8')
+            # cookie = random_item[0].decode('utf-8')
+            cookie = cookie_update.get_cookie_handler()
             phone_num = int(random_item[1])
             phone_num = int(random_item[1])
 
 
             headers = {'User-Agent': 'Mozilla/5.0',
             headers = {'User-Agent': 'Mozilla/5.0',

+ 2 - 1
spider/SpiderPromoterHeaderRocket.py

@@ -34,7 +34,8 @@ class SpiderPromoterHeader:
         else:
         else:
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_item = random.choice(random_member)
             random_item = random.choice(random_member)
-            cookie = random_item[0].decode('utf-8')
+            # cookie = random_item[0].decode('utf-8')
+            cookie = cookie_update.get_cookie_handler()
             phone_num = int(random_item[1])
             phone_num = int(random_item[1])
 
 
             headers = {'User-Agent': 'Mozilla/5.0',
             headers = {'User-Agent': 'Mozilla/5.0',

+ 2 - 1
spider/SpiderPromoterInfo.py

@@ -29,7 +29,8 @@ class SpiderPromoterInfo:
         else:
         else:
             random_member = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
             random_member = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
             random_item = random.choice(random_member)
             random_item = random.choice(random_member)
-            cookie = random_item[0].decode('utf-8')
+            # cookie = random_item[0].decode('utf-8')
+            cookie = cookie_update.get_cookie_handler()
             phone_num = int(random_item[1])
             phone_num = int(random_item[1])
             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
 
 

+ 2 - 1
spider/SpiderWeekPromoterInfo.py

@@ -37,7 +37,8 @@ class SpiderWeekPromoterInfo:
         else:
         else:
             random_member = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
             random_member = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
             random_item = random.choice(random_member)
             random_item = random.choice(random_member)
-            cookie = random_item[0].decode('utf-8')
+            # cookie = random_item[0].decode('utf-8')
+            cookie=cookie_update.get_cookie_handler()
             phone_num = int(random_item[1])
             phone_num = int(random_item[1])
             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
 
 

+ 12 - 5
utils/PromoterInfoWebHook.py

@@ -46,7 +46,8 @@ def webhook_get_promoter():
             cookie_update.get_click_coookie_to_redis()
             cookie_update.get_click_coookie_to_redis()
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_item = random.choice(random_member)
             random_item = random.choice(random_member)
-            cookie = random_item[0].decode('utf-8')
+            cookie = cookie_update.get_cookie_handler()
+            # cookie = random_item[0].decode('utf-8')
             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
             print(roll, '-----000-----{promoterId}'.format(promoterId=promoterId))
             print(roll, '-----000-----{promoterId}'.format(promoterId=promoterId))
             return roll
             return roll
@@ -55,7 +56,8 @@ def webhook_get_promoter():
         else:
         else:
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
             random_item = random.choice(random_member)
             random_item = random.choice(random_member)
-            cookie = random_item[0].decode('utf-8')
+            # cookie = random_item[0].decode('utf-8')
+            cookie = cookie_update.get_cookie_handler()
             print(cookie,'----------cookie--------------')
             print(cookie,'----------cookie--------------')
             phone_num = int(random_item[1])
             phone_num = int(random_item[1])
             print(phone_num,'------phone_num-------')
             print(phone_num,'------phone_num-------')
@@ -66,7 +68,9 @@ def webhook_get_promoter():
                     r.zrem('kuaishou_shop_click_token', random_item[0])
                     r.zrem('kuaishou_shop_click_token', random_item[0])
                     retry_item = cookie_update.r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
                     retry_item = cookie_update.r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
                     print(retry_item[0][0], '-----cookie-----')
                     print(retry_item[0][0], '-----cookie-----')
-                    retry_cookie = retry_item[0][0].decode('utf-8')
+                    retry_cookie = cookie_update.get_cookie_handler()
+
+                    # retry_cookie = retry_item[0][0].decode('utf-8')
                     cookie_update.update_cookie_handler(phone_num)
                     cookie_update.update_cookie_handler(phone_num)
                     rollback = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
                     rollback = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
                     p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
                     p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
@@ -91,7 +95,9 @@ def webhook_get_promoter():
                     r.zrem('kuaishou_shop_click_token', random_item[0])
                     r.zrem('kuaishou_shop_click_token', random_item[0])
 
 
                     retry_item = cookie_update.r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
                     retry_item = cookie_update.r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
-                    retry_cookie = retry_item[0][0].decode('utf-8')
+                    # retry_cookie = retry_item[0][0].decode('utf-8')
+                    retry_cookie = cookie_update.update_cookie_handler(phone_num)
+
                     rolls = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
                     rolls = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
                     p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
                     p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, retry_cookie))
                     p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, retry_cookie))
                     p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, retry_cookie))
@@ -151,7 +157,8 @@ def webhook_update_promoter():
     else:
     else:
         random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
         random_member = r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
         random_item = random.choice(random_member)
         random_item = random.choice(random_member)
-        cookie = random_item[0].decode('utf-8')
+        # cookie = random_item[0].decode('utf-8')
+        cookie= cookie_update.get_cookie_handler()
         ReturnPromoterInfoSpider().PromoterUpdate(promoterId, cookie)
         ReturnPromoterInfoSpider().PromoterUpdate(promoterId, cookie)
         r.close()
         r.close()
     return '0'
     return '0'