|
@@ -24,12 +24,12 @@ from utils.send_feishu_msg import SendFeiShuMsg
|
|
|
|
|
|
|
|
|
|
class SpiderPromoterInfo:
|
|
class SpiderPromoterInfo:
|
|
- def __init__(self):
|
|
|
|
- self.r = redis.Redis(host='192.168.0.193', password='hcst@2022', port=6379, db=0)
|
|
|
|
- self.conn = MysqlProUtils()
|
|
|
|
|
|
+ r = redis.Redis(host='192.168.0.193', password='hcst@2022', port=6379, db=0)
|
|
|
|
+ conn = MysqlProUtils()
|
|
|
|
|
|
- def get_promoter(self, promoterId):
|
|
|
|
- if self.r.zcard('kuaishou_shop_token') == 0:
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def get_promoter(promoterId):
|
|
|
|
+ if SpiderPromoterInfo.r.zcard('kuaishou_shop_token') == 0:
|
|
cookie_update.get_coookie_to_redis()
|
|
cookie_update.get_coookie_to_redis()
|
|
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)
|
|
@@ -46,12 +46,25 @@ class SpiderPromoterInfo:
|
|
"cookie 永久失效 轻更新cookie 唯一电话为{phone_num}".format(phone_num=phone_num))
|
|
"cookie 永久失效 轻更新cookie 唯一电话为{phone_num}".format(phone_num=phone_num))
|
|
retry_item = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
|
|
retry_item = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
|
|
retry_cookie = retry_item[0].decode('utf-8')
|
|
retry_cookie = retry_item[0].decode('utf-8')
|
|
|
|
+ roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
|
|
+
|
|
cookie_update.update_cookie_handler(phone_num)
|
|
cookie_update.update_cookie_handler(phone_num)
|
|
PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
|
|
PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
|
|
PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
|
|
PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_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])
|
|
|
|
|
|
else:
|
|
else:
|
|
|
|
|
|
@@ -63,43 +76,60 @@ class SpiderPromoterInfo:
|
|
|
|
|
|
retry_item = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
|
|
retry_item = cookie_update.r.zrange('kuaishou_shop_token', 0, -1, withscores=True)
|
|
retry_cookie = retry_item[0].decode('utf-8')
|
|
retry_cookie = retry_item[0].decode('utf-8')
|
|
|
|
+ roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
|
|
PromoterFansInfo().PromoterFansInfoHandler(promoterId, retry_cookie)
|
|
PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
|
|
PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_cookie)
|
|
PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId, retry_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])
|
|
|
|
|
|
else:
|
|
else:
|
|
- self.update_promoter_info(promoterId)
|
|
|
|
PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
|
|
PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
|
|
PromoterFansInfo().PromoterFansInfoHandler(promoterId, cookie)
|
|
PromoterFansInfo().PromoterFansInfoHandler(promoterId, cookie)
|
|
PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, cookie)
|
|
PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId, cookie)
|
|
PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, cookie)
|
|
PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId, cookie)
|
|
PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(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])
|
|
cookie_update.r.zrem('kuaishou_shop_token', random_item[0])
|
|
return roll
|
|
return roll
|
|
|
|
|
|
- def get_promoter_info(self):
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def get_promoter_info():
|
|
sql = """
|
|
sql = """
|
|
select promoter_id from ruixuan.kuaishou_promoter where media_id =2
|
|
select promoter_id from ruixuan.kuaishou_promoter where media_id =2
|
|
"""
|
|
"""
|
|
- promoter_result = self.conn.QueryAll(sql)
|
|
|
|
- for promoter in promoter_result:
|
|
|
|
- promoter_id = int(promoter[0].decode('utf-8'))
|
|
|
|
- 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)
|
|
|
|
|
|
+ promoter_result = SpiderPromoterInfo.conn.QueryAll(sql)
|
|
|
|
+ SpiderPromoterInfo.r.rpush('promoter_list', *promoter_result)
|
|
|
|
+
|
|
|
|
+ try:
|
|
|
|
+ for promoter in promoter_result:
|
|
|
|
+ promoter_id = int(promoter[0].decode('utf-8'))
|
|
|
|
+
|
|
|
|
+ SpiderPromoterInfo.get_promoter(promoter_id)
|
|
|
|
+ time.sleep(2)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|