12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- """
- Author renyupeng
- coding=utf-8
- @Time : 2023/2/9 11:04 上午
- @Site :
- @File : PromoterVideoAnalysisInfo.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 PromoterVideoAnalysisInfo:
- def __init__(self):
- self.conn = MysqlUtils()
- self.list = [1, 2, 3]
- def PromoterVideoAnalysisInfoHandler(self, promoterId):
- sql = "select cookie from ruixuan.kuaishou_supply_chain_cookie"
- cookie = self.conn.QueryOne(sql)[0]
- headers = {'User-Agent': 'Mozilla/5.0',
- 'Cookie': cookie}
- try:
- for i in self.list:
- url = "https://cps.kwaixiaodian.com/gateway/distribute/platform/seller" \
- "/promoter/video/analysis/key/indicator?promoterId={promoterId}&timeRangeType={timeRangeType}" \
- .format(timeRangeType=i, promoterId=promoterId)
- rep = requests.get(url=url, headers=headers)
- table_name = 'kwai_promoter_video_info'
- data = json.loads(rep.text)["data"]
- promoter_video_item = {"commentCount": data["commentCount"], "likeCount": data["likeCount"],
- "shareCount": data["shareCount"], "totalSale": data["totalSale"],
- "videoCount": data["videoCount"],
- "videoWatchCount": data["videoWatchCount"],
- "timeRangeType": i, "promoterId": data["promoterId"]}
- insert(table_name=table_name, item=promoter_video_item)
- except Exception as e:
- SendFeiShuMsg.send_robot_msg('请求错误请检查cookie{e}'.format(e=e))
|