1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- """
- 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 {promoterId请求错误请检查cookie{e}'.format(promoterId=promoterId, e=e))
- return {"error": "requestsError"}
|