| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | 
							- """
 
- 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.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)
 
-             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"],
 
-             }
 
-             returnItemJson = json.dumps(returnItem)
 
-             return returnItemJson
 
-         except Exception as e:
 
-             SendFeiShuMsg.send_robot_msg('ReturnPromoterInfoSpider请求错误请检查cookie{e}'.format(e=e))
 
-             return {"error": "requestsError"}
 
 
  |