renyupeng 1 年之前
父节点
当前提交
696ff99cf3
共有 2 个文件被更改,包括 25 次插入32 次删除
  1. 0 1
      spider/ReturnPromoterInfoSpider.py
  2. 25 31
      spider/SpiderWeekPromoterInfo.py

+ 0 - 1
spider/ReturnPromoterInfoSpider.py

@@ -64,7 +64,6 @@ class ReturnPromoterInfoSpider:
 
         try:
             rep = requests.get(url=url, headers=headers)
-            print(rep.text)
             if json.loads(rep.text)["result"] != 1:
                 errItem = {"result": json.loads(rep.text)["result"]}
                 return json.dumps(errItem)

+ 25 - 31
spider/SpiderWeekPromoterInfo.py

@@ -39,7 +39,6 @@ class SpiderWeekPromoterInfo:
             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
 
             if json.loads(roll).__contains__("result"):
-                print(11111)
                 if json.loads(roll)["result"] == 100110000:
                     cookie_update.r.zrem('kuaishou_shop_token', random_item[0])
                     SendFeiShuMsg.send_cookie_robot_msg(
@@ -47,11 +46,11 @@ class SpiderWeekPromoterInfo:
                     retry_item = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
                     retry_cookie = retry_item[0].decode('utf-8')
                     cookie_update.update_cookie_handler(phone_num)
-                    PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
-                    PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
-                    PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
-                    PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
-                    PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_cookie)
+                    # PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
+                    # PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
+                    # PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
+                    # PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
+                    # PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_cookie)
 
                 else:
 
@@ -63,22 +62,29 @@ class SpiderWeekPromoterInfo:
 
                     retry_item = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
                     retry_cookie = retry_item[0].decode('utf-8')
-                    PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
-                    PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
-                    PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
-                    PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
-                    PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_cookie)
+                    # PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
+                    # PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
+                    # PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
+                    # PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
+                    # PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_cookie)
 
             else:
-                self.update_promoter_info(promoterId)
-                PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
-                PromoterFansInfo().PromoterFansInfoHandler(promoterId, cookie)
-                PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, cookie)
-                PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, cookie)
-                PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, cookie)
-
+                # PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
+                # PromoterFansInfo().PromoterFansInfoHandler(promoterId, cookie)
+                # PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, cookie)
+                # PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, cookie)
+                # PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, cookie)
+                roll = json.loads(roll)
+                fanNum = roll["fanNum"]
+                totalSale = roll["totalSale"]
+                avgVideoSales = roll["avgVideoSales"]
+                videoSales = roll["videoSales"]
+                sql = """ replace into ruixuan.promoter_sales_info(promoter_id, total_sale, fans_number, avg_video_sales, video_sales) values (
+                {promoterId},'{totalSale}',{fanNum},'{avgVideoSales}','{videoSales}'
+                ) """.format(totalSale=totalSale, fanNum=fanNum, avgVideoSales=avgVideoSales, videoSales=videoSales,
+                             promoterId=promoterId)
+                MysqlProUtils().Operate(sql=sql)
                 cookie_update.r.zrem('kuaishou_shop_token', random_item[0])
-                return roll
 
     def get_promoter_info(self):
         sql = """
@@ -90,18 +96,6 @@ class SpiderWeekPromoterInfo:
             self.get_promoter(promoter_id)
             time.sleep(2)
 
-    def update_promoter_info(self, promoter_id):
-        roll = self.get_promoter(promoter_id)
-        fanNum = roll['fanNum']
-        totalSale = roll["promoteBaseInfo"]["totalSale"]
-        avgVideoSales = roll["promoteBaseInfo"]["avgVideoSales"]
-        videoSales = roll["promoteBaseInfo"]["videoSales"]
-        sql = """ replace into ruixuan.promoter_sales_info(promoter_id, total_sale, fans_number, avg_video_sales, video_sales) values (
-    {promoterId},'{totalSale}',{fanNum},'{avgVideoSales}','{videoSales}'
-         """.format(totalSale=totalSale, fanNum=fanNum, avgVideoSales=avgVideoSales, videoSales=videoSales,
-                    promoterId=promoter_id)
-        MysqlProUtils().Operate(sql=sql)
-
 
 if __name__ == '__main__':
     SpiderWeekPromoterInfo().get_promoter_info()