| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | 
							- """
 
- Author renyupeng
 
- coding=utf-8
 
- @Time    : 2023/2/7 2:34 下午
 
- @Site    :
 
- @File    : ReturnPromoterInfoSpider.py
 
- @Software: PyCharm
 
- @contact: renyupeng@c-top.com.cn
 
- @Tel 1501435553
 
- """
 
- import json
 
- import requests
 
- from utils.cookie_update import cookie_update
 
- from utils.mysql_helper import insert
 
- from utils.mysql_utils import MysqlUtils
 
- from utils.send_feishu_msg import SendFeiShuMsg
 
- class ReturnPromoterInfoSpider:
 
-     def __init__(self):
 
-         self.conn = MysqlUtils()
 
-     @staticmethod
 
-     def PromoterInfoSpiderHandler(promoterId, cookie):
 
-         url = 'https://cps.kwaixiaodian.com/distribute/pc/seller/promoter/info?promoterId={promoterId}&type=1'.format(
 
-             promoterId=promoterId)
 
-         headers = {'User-Agent': 'Mozilla/5.0',
 
-                    'Cookie': cookie}
 
-         try:
 
-             rep = requests.get(url=url, headers=headers)
 
-             if json.loads(rep.text)["result"] != 1:
 
-                 errItem = {"result": json.loads(rep.text)["result"]}
 
-                 return json.dumps(errItem)
 
-             else:
 
-                 data = json.loads(rep.text)["data"]
 
-                 returnItem = {
 
-                     "city": data["addressInfo"]["city"],
 
-                     "province": data["addressInfo"]["province"],
 
-                     "fanNum": data["fanNum"],
 
-                     "promoterHeadImgUrl": data["promoterHeadImgUrl"],
 
-                     "promoterNickName": data["promoterNickName"],
 
-                     "totalSale": data["promoteBaseInfo"]["totalSale"],
 
-                     "avgVideoSales": data["promoteBaseInfo"]["avgVideoSales"],
 
-                     "videoSales": data["promoteBaseInfo"]["videoSales"]
 
-                 }
 
-                 returnItemJson = json.dumps(returnItem)
 
-                 return returnItemJson
 
-         except Exception as e:
 
-             SendFeiShuMsg.send_robot_msg(
 
-                 'ReturnPromoterInfoSpider {promoterId}请求错误请检查cookie{e}'.format(promoterId=promoterId, e=e))
 
 
  |