Prechádzať zdrojové kódy

增加快手全品类启动脚本

zhangyong 8 mesiacov pred
rodič
commit
53117236ee

+ 15 - 0
common/sql_help.py

@@ -122,3 +122,18 @@ class sqlCollect():
             sql=insert_sql
         )
         return res
+
+    """
+    获取相似溯源基础账号
+    """
+    @classmethod
+    def get_machine_making_reflux(cls, channel):
+        sql = """
+                        SELECT user
+                        FROM machine_making_reflux
+                        WHERE channel = %s and status = 0
+                    """
+        data = MysqlHelper.get_values(sql, (channel))
+        if len(data) == 0 or data == ():
+            return None
+        return data

+ 96 - 0
data_channel/cljx_nrxs.py

@@ -0,0 +1,96 @@
+import time
+
+import requests
+import json
+
+from common import Feishu
+from common.sql_help import sqlCollect
+
+
+class CLJX:
+
+    @classmethod
+    def get_ks_account_id(cls, user_id):
+        url = "http://8.217.190.241:8888/crawler/kuai_shou/account_info"
+        payload = json.dumps({
+            "account_id": user_id,
+
+        })
+        headers = {
+            'Content-Type': 'application/json'
+        }
+        response = requests.request("POST", url, headers=headers, data=payload)
+        time.sleep(1)
+        response = response.json()
+        code = response['code']
+        if code == 0:
+            data = response['data']['data']
+            if '3x' in user_id:
+                channel_account_id = data['digit_id']
+            else:
+                channel_account_id = data['channel_account_id']
+
+            return channel_account_id
+        else:
+            Feishu.finish_bot("kuai_shou/account_info接口"+response["msg"],
+                              "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb",
+                              "【快手 Token 使用提示 】")
+            return None
+
+    @classmethod
+    def get_nrxs(cls):
+        user = sqlCollect.get_machine_making_reflux("快手")
+        if user == None:
+            return
+        user = [item[0] for item in user]
+        for id in user:
+            ks_id = cls.get_ks_account_id(id)
+            url = "https://k.kuaishou.com/rest/web/similar/simStar/list"
+
+            payload = json.dumps({
+                "next": 0,
+                "similarType": 1,
+                "size": 10,
+                "starUserId": ks_id
+            })
+            headers = {
+                'Accept': 'application/json',
+                'Accept-Language': 'zh-CN,zh;q=0.9',
+                'Content-Type': 'application/json',
+                'Cookie': 'did=web_9c6a04a4004fdb7c95a658a56ed275b6; apdid=328ac94f-4040-41fe-a038-b60140291aca99fb22e9862c74736f53d57b666ee53b:1719580529:1; language=zh-CN; ud=2205012540; app_id=ks686235996059836592; expire_time=1800; userId=2574854626; didv=1723085291918; access_token=ChFvYXV0aC5hY2Nlc3NUb2tlbhIwDJriiBd_Rfw8eDYAcNrxMNVh31u9tSJA9CAjt2O16wxi9gaDtJGN2IvVJqfPwZSwGhITB63P569DkqhlagGy21IJcH4iIHbikbQYx3YJ52cgLTbYnP5Huwfrx7NEoKGZIe1AAyeIKAUwAQ; nc_user_id=CiVhZC5ub3RpZnkuY2VudGVyLm9hdXRoLnVzZXIuaWQuc2VjcmV0EiC/P102mzVQGt2+DLIVD/C0wyWnJS85OkfLevE+gvyLiRoSh6GwxLxhJBzTF971M5HbMVVPIiDgi55t2xTmfnFXnyeAyDLyzno6k2e/bw7J4u1/qifbhSgFMAE=; kuaishou.ad.social_st=ChVrdWFpc2hvdS5hZC5zb2NpYWwuc3QSoAEqrrb6oCuZkjOnvnZeoEnQ564Rqph6-AqPSgVWYrifAPjBt2YgfXHw_98ldMOg8cUR8QiOIFztsdcRTBYDvs_ckIgjC5UiJTT55LXHG8ANCYQI4NZunxSDkRjtJAxK0R-21t3-rClsYus5eFEwaBnhuD0cG_Ze5a1ZWgkliCTZRHodiOTLWKP8exhEEg6lQnWPJe3YwCi91Setn1Vj6UKjGhLsLDZ7p_FIhoJA3z3VbOn1dpkiIIaFUhkgfk2L9XCNiZIVUGL6Bs0hCk9Kqgm6HdnYn7FBKAUwAQ; kuaishou.ad.social_ph=35a38517bc185742d657a2ac0ba1e8f4a088; did=web_9c6a04a4004fdb7c95a658a56ed275b6; didv=1711522726000',
+                'Origin': 'https://k.kuaishou.com',
+                'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
+                'sec-ch-ua-platform': '"macOS"'
+            }
+
+            response = requests.request("POST", url, headers=headers, data=payload)
+            time.sleep(1)
+            response = response.json()
+            result = response['result']
+            if result == 1:
+                data = response["data"]
+                star_vo_list = data['starVoList']
+                for star in star_vo_list:
+                    user_id = star['userId']
+                    name = star['name']
+                    account_id = cls.get_ks_account_id(str(user_id))
+                    if account_id:
+                        print(account_id)
+                        values = [
+                            [
+                                id,
+                                name,
+                                account_id
+                            ]
+                        ]
+                        Feishu.insert_columns("AIW2sNNjdhCgT3tug7sco7FGnse", '727a17', "ROWS", 1, 2)
+                        time.sleep(0.5)
+                        Feishu.update_values("AIW2sNNjdhCgT3tug7sco7FGnse", '727a17', "A2:Z2", values)
+            else:
+                print("提示")
+                Feishu.finish_bot("Token 过期,请及时更换",
+                                  "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb",
+                                  "【磁力聚星提示】")
+
+if __name__ == '__main__':
+    CLJX.get_nrxs()

+ 0 - 0
data_channel/dy_nrxs.py


+ 2 - 2
data_channel/ks_ls.py

@@ -29,8 +29,8 @@ class KSLS:
             if data_all_list == None or len(data_all_list) == 0:
                 try:
                     if int(response["cdoe"]) == 27006:
-                        Feishu.finish_bot(response["msg"],
-                                          "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb", "【 Token 使用提示 】")
+                        Feishu.finish_bot("kuai_shou/blogger接口"+response["msg"],
+                                          "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb", "【快手 Token 使用提示 】")
                 except Exception as exc:
                     return list
 

+ 0 - 0
data_channel/ks_nrxs.py


+ 129 - 123
data_channel/qpl_ks.py

@@ -12,19 +12,25 @@ from common.sql_help import sqlCollect
 class QplKs:
     @classmethod
     def ks_data_list(cls):
-        content_type = [{'美食': '673'}, {'短剧': '674'}, {'时尚': '675'}, {'母婴亲子': '676'}, {'生活': '677'},
-                        {'汽车': '678'}, {'旅游': '679'}, {'体育运动': '680'}, {'艺术文化': '682'}, {'房产家居': '683'},
-                        {'健康医疗': '684'}, {'教育培训': '685'}, {'高新数码': '686'}, {'音乐': '687'}, {'舞蹈': '688'}, {'读书': '689'},
-                        {'摄影': '704'},
-                        {'财经投资': '690'}, {'萌宠': '691'}, {'时政资讯': '692'}, {'科学与法律': '693'}, {'三农': '694'}, {'搞笑': '695'},
-                        {'情感': '696'},
-                        {'人文': '697'}, {'星座命理': '699'}, {'奇人异象': '700'}, {'军事': '701'}, {'影视娱乐': '702'},
-                        {'民生资讯': '703'}, {'健身达人': '706'}, {'纪实类': '705'}]
-        # fans_count = [{0: 100000}, {100000: 1000000}, {1000000: 3000000}, {3000000: 5000000}, {5000000: 10000000},
-        #               {10000000: 0}]
-
-
-        fans_count = [{10000000: 0}, {5000000: 10000000}]
+        # content_type = [{'美食': '673'}, {'旅游': '679'}, {'音乐': '687'}, {'时政资讯': '692'},  {'健康医疗': '684'},
+        #                 {'军事': '701'}, {'教育培训': '685'}, {'生活': '677'}, {'舞蹈': '688'},
+        #                 {'母婴亲子': '676'}, {'萌宠': '691'}, {'情感': '696'}, {'搞笑': '695'}, {'人文': '697'},
+        #                 {'三农': '694'}, {'科学与法律': '693'}, {'读书': '689'}, {'奇人异象': '700'}, {'民生资讯': '703'},
+        #                 {'纪实类': '705'}, {'财经投资': '690'}, {'摄影': '704'}, {'艺术文化': '682'}, {'房产家居': '683'},
+        #                 {'短剧': '674'}, {'时尚': '675'}, {'影视娱乐': '702'}, {'体育运动': '680'}, {'健身达人': '706'},
+        #                 {'星座命理': '699'},  {'汽车': '678'}, {'高新数码': '686'}]
+        content_type = [{'旅游': '679'}, {'音乐': '687'}, {'时政资讯': '692'}, {'健康医疗': '684'},
+                        {'军事': '701'}, {'教育培训': '685'}, {'生活': '677'}, {'舞蹈': '688'},
+                        {'母婴亲子': '676'}, {'萌宠': '691'}, {'情感': '696'}, {'搞笑': '695'}, {'人文': '697'},
+                        {'三农': '694'}, {'科学与法律': '693'}, {'读书': '689'}, {'奇人异象': '700'}, {'民生资讯': '703'},
+                        {'纪实类': '705'}, {'财经投资': '690'}, {'摄影': '704'}, {'艺术文化': '682'}, {'房产家居': '683'},
+                        {'短剧': '674'}, {'时尚': '675'}, {'影视娱乐': '702'}, {'体育运动': '680'}, {'健身达人': '706'},
+                        {'星座命理': '699'}, {'汽车': '678'}, {'高新数码': '686'}]
+        fans_count = [{0: 100000}, {100000: 1000000}, {1000000: 3000000}, {3000000: 5000000}, {5000000: 10000000},
+                      {10000000: 0}]
+
+
+        # fans_count = [{10000000: 0}, {5000000: 10000000}]
         url = "https://k.kuaishou.com/rest/web/star/list"
         headers = {
             'Accept': 'application/json',
@@ -36,118 +42,118 @@ class QplKs:
             'Referer': 'https://k.kuaishou.com/',
             'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
         }
-        # for count in fans_count:
-        #     (fans_min_num, fans_max_num), = count.items()
-        for content in content_type:
-            (content_name, content_id), = content.items()
-            current_page = 1
-            while True:
-                payload_data = {
-                    "currentPage": current_page,
-                    "pageSize": 20,
-                    "starOrderTag": 3,
-                    "taskType": 1,
-                    "marketingGoal": 1,
-                    "viewerAgeList": [  # 观众画像 50+
-                        {
-                            "from": "0.50",
-                            "to": "1.00",
-                            "queryName": "50+"
-                        }
-                    ],
-                    "userName": "",
-                    "vitalityTags": [  # 活跃度 近期短视频活跃
-                        "668"
-                    ],
-                    "contentTagIdList": [  # 内容类型
-                        {
-                            "id": str(content_id),
-                            "selectFirstLevelId": True
-                        }
-                    ],
-                    "starTagIds": [  # 高调性
-                        13
-                    ]
-                    # "fansMinNum": 1000000,  # 粉丝数量
-                    # "fansMaxNum": 3000000,  # 粉丝数量
-                }
-                # if fans_min_num > 0:
-                #     payload_data["fansMinNum"] = fans_min_num
-                # if fans_max_num > 0:
-                #     payload_data["fansMaxNum"] = fans_max_num
-                payload = json.dumps(payload_data)
-
-                time.sleep(random.randint(10, 20))
-                response = requests.request("POST", url, headers=headers, data=payload)
-                response = response.json()
-                print(f"开始扫描{content}")
-
-                result = response["result"]
-                if result == 1:
-                    total = response["total"]  # 总条数
-                    if total == 0:
-                        print(f"没有扫描到数据{content}")
-                        break
-                    star_list = response["starList"]
-                    if len(star_list) == 0 or star_list == []:
-                        break
-                    for star in star_list:
-                        print(f"扫描到一条数据{content}")
-                        user_id = star["userId"]
-                        star_id = star["starId"]
-                        name = star["name"]  # 用户名
-                        kwai_id = star["kwaiId"]  # 用户名id
-                        gender = star["gender"]  # 性别
-                        fans_number = star["fansNumber"]  # 粉丝数
-                        profile_id = star["profileId"]  # 主页id
-                        star_tag_str = star["starTagStr"]  # 内容类型1
-                        industry_tag_str = star["industryTagStr"]  # 内容类型2
-                        photo_expect_play = star["photoExpectPlay"]  # 预期播放量
-                        photo_expect_cpm = star["photoExpectCpm"]  # 预期CPM
-                        photo_interaction_rate = star["photoInteractionRate"]  # 互动率
-                        photo_complete_play_rate = star["photoCompletePlayRate"]  # 完播率
-                        fans_increase_num = star["fansIncreaseNum"]  # 粉丝增长量
-                        fans_increase_rate = star["fansIncreaseRate"]  # 粉丝增长率
-                        # res = sqlCollect.insert_ks_qpl_data(user_id, star_id, name, kwai_id, gender, fans_number, profile_id, star_tag_str, industry_tag_str, photo_expect_play, photo_expect_cpm, photo_interaction_rate, photo_complete_play_rate, fans_increase_num, fans_increase_rate)
-                        # if res == 1:
-                        current_time = datetime.now()
-                        formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
-                            # if fans_min_num == 0:
-                            #     fans = f"{fans_max_num}及以下"
-                            # if fans_max_num == 0:
-                            #     fans = f"{fans_min_num}及以上"
-                            # else:
-                            #     fans = f"{fans_min_num}~{fans_max_num}"
-                        values = [
-                            [
-                                name,
-                                gender,
-                                fans_number,
-                                profile_id,
-                                "https://www.kuaishou.com/profile/"+profile_id,
-                                star_tag_str,
-                                industry_tag_str,
-                                photo_expect_play,
-                                photo_expect_cpm,
-                                photo_interaction_rate,
-                                photo_complete_play_rate,
-                                fans_increase_num,
-                                fans_increase_rate,
-                                # fans,
-                                formatted_time
+        for count in fans_count:
+            (fans_min_num, fans_max_num), = count.items()
+            for content in content_type:
+                (content_name, content_id), = content.items()
+                current_page = 1
+                while True:
+                    payload_data = {
+                        "currentPage": current_page,
+                        "pageSize": 20,
+                        "starOrderTag": 3,
+                        "taskType": 1,
+                        "marketingGoal": 1,
+                        "viewerAgeList": [  # 观众画像 50+
+                            {
+                                "from": "0.50",
+                                "to": "1.00",
+                                "queryName": "50+"
+                            }
+                        ],
+                        "userName": "",
+                        "vitalityTags": [  # 活跃度 近期短视频活跃
+                            "668"
+                        ],
+                        "contentTagIdList": [  # 内容类型
+                            {
+                                "id": str(content_id),
+                                "selectFirstLevelId": True
+                            }
+                        ],
+                        # "starTagIds": [  # 高调性
+                        #     13
+                        # ]
+                        # "fansMinNum": 1000000,  # 粉丝数量
+                        # "fansMaxNum": 3000000,  # 粉丝数量
+                    }
+                    if fans_min_num > 0:
+                        payload_data["fansMinNum"] = fans_min_num
+                    if fans_max_num > 0:
+                        payload_data["fansMaxNum"] = fans_max_num
+                    payload = json.dumps(payload_data)
+
+                    time.sleep(random.randint(10, 20))
+                    response = requests.request("POST", url, headers=headers, data=payload)
+                    response = response.json()
+                    print(f"开始扫描{content}")
+
+                    result = response["result"]
+                    if result == 1:
+                        total = response["total"]  # 总条数
+                        if total == 0:
+                            print(f"没有扫描到数据{content}")
+                            break
+                        star_list = response["starList"]
+                        if len(star_list) == 0 or star_list == []:
+                            break
+                        for star in star_list:
+                            print(f"扫描到一条数据{content}")
+                            user_id = star["userId"]
+                            star_id = star["starId"]
+                            name = star["name"]  # 用户名
+                            kwai_id = star["kwaiId"]  # 用户名id
+                            gender = star["gender"]  # 性别
+                            fans_number = star["fansNumber"]  # 粉丝数
+                            profile_id = star["profileId"]  # 主页id
+                            star_tag_str = star["starTagStr"]  # 内容类型1
+                            industry_tag_str = star["industryTagStr"]  # 内容类型2
+                            photo_expect_play = star["photoExpectPlay"]  # 预期播放量
+                            photo_expect_cpm = star["photoExpectCpm"]  # 预期CPM
+                            photo_interaction_rate = star["photoInteractionRate"]  # 互动率
+                            photo_complete_play_rate = star["photoCompletePlayRate"]  # 完播率
+                            fans_increase_num = star["fansIncreaseNum"]  # 粉丝增长量
+                            fans_increase_rate = star["fansIncreaseRate"]  # 粉丝增长率
+                            # res = sqlCollect.insert_ks_qpl_data(user_id, star_id, name, kwai_id, gender, fans_number, profile_id, star_tag_str, industry_tag_str, photo_expect_play, photo_expect_cpm, photo_interaction_rate, photo_complete_play_rate, fans_increase_num, fans_increase_rate)
+                            # if res == 1:
+                            current_time = datetime.now()
+                            formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
+                            if fans_min_num == 0:
+                                fans = f"{fans_max_num}及以下"
+                            if fans_max_num == 0:
+                                fans = f"{fans_min_num}及以上"
+                            else:
+                                fans = f"{fans_min_num}~{fans_max_num}"
+                            values = [
+                                [
+                                    name,
+                                    gender,
+                                    fans_number,
+                                    profile_id,
+                                    "https://www.kuaishou.com/profile/"+profile_id,
+                                    star_tag_str,
+                                    industry_tag_str,
+                                    photo_expect_play,
+                                    photo_expect_cpm,
+                                    photo_interaction_rate,
+                                    photo_complete_play_rate,
+                                    fans_increase_num,
+                                    fans_increase_rate,
+                                    fans,
+                                    formatted_time
+                                ]
                             ]
-                        ]
-                        Feishu.insert_columns("GjGZsmW2ahaCe4tmzDTc58tVnbe", "emf56g", "ROWS", 1, 2)
-                        time.sleep(0.5)
-                        Feishu.update_values("GjGZsmW2ahaCe4tmzDTc58tVnbe", "emf56g", "A2:Z2", values)
-                        print(f"入库到一条数据{content}")
-                    current_page += 1
-                    if total < 20:
-                        break
-                    else:
-                        page = int(total)/20
-                        if current_page > int(page)+1:
+                            Feishu.insert_columns("GjGZsmW2ahaCe4tmzDTc58tVnbe", "COyUUm", "ROWS", 1, 2)
+                            time.sleep(0.5)
+                            Feishu.update_values("GjGZsmW2ahaCe4tmzDTc58tVnbe", "COyUUm", "A2:Z2", values)
+                            print(f"入库到一条数据{content}")
+                        current_page += 1
+                        if total < 20:
                             break
+                        else:
+                            page = int(total)/20
+                            if current_page > int(page)+1:
+                                break
 
 
 

+ 4 - 0
ks_qpl_main.py

@@ -0,0 +1,4 @@
+from data_channel.qpl_ks import QplKs
+
+if __name__ == '__main__':
+    QplKs.ks_data_list()