| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | 
							- # Author renyupeng
 
- # coding=utf-8
 
- # @Time    : 2023/9/11 下午4:19
 
- # @Site    :
 
- # @File    : SpiderPromoterInfo.py
 
- # @Software: PyCharm
 
- # @contact: renyupeng@c-top.com.cn
 
- # @Tel 1501435553
 
- import json
 
- import threading
 
- import time
 
- import random
 
- import redis
 
- from spider.ReturnPromoterInfoSpider import ReturnPromoterInfoSpider
 
- from utils.cookie_update import cookie_update
 
- from utils.mysql_utils_pro import MysqlProUtils
 
- class SpiderPromoterInfo:
 
-     conn = MysqlProUtils()
 
-     @staticmethod
 
-     def get_promoter(promoterId):
 
-         print(promoterId, '22222')
 
-         cookie = cookie_update.get_cookie_handler()[0]
 
-         roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
 
-         print(roll, '------')
 
-         if json.loads(roll).__contains__("result"):
 
-             retry_cookie = cookie_update.get_cookie_handler()[0]
 
-             roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
 
-             try:
 
-                 roll = json.loads(roll)
 
-                 fanNum = roll["fanNum"]
 
-                 totalSale = roll["totalSale"]
 
-                 avgVideoSales = roll["avgVideoSales"]
 
-                 videoSales = roll["videoSales"]
 
-                 sql = """ replace into miaogousi.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)
 
-             except Exception as e:
 
-                 print(e)
 
-         else:
 
-             roll = json.loads(roll)
 
-             print(roll, '--roll--', promoterId)
 
-             fanNum = roll["fanNum"]
 
-             totalSale = roll["totalSale"]
 
-             avgVideoSales = roll["avgVideoSales"]
 
-             videoSales = roll["videoSales"]
 
-             sql = """ replace into miaogousi.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)
 
-     @staticmethod
 
-     def get_promoter_info():
 
-         sql = """
 
-    select a.promoter_id from miaogousi.kuaishou_promoter  a
 
-    left join miaogousi.promoter_sales_info b
 
-    on a.promoter_id=b.promoter_id
 
-    where  a.media_id=2
 
-      and a.create_time>=date_format(date_sub(now(),interval 10 day),'%Y-%m-%d')
 
-      """
 
-         promoter_result = SpiderPromoterInfo.conn.QueryAll(sql)
 
-         for promoter in promoter_result:
 
-             promoter_id = promoter[0].decode('utf-8')
 
-             SpiderPromoterInfo.get_promoter(promoter_id)
 
-             time.sleep(30)
 
- if __name__ == '__main__':
 
-     SpiderPromoterInfo.get_promoter_info()
 
 
  |