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