wangkun vor 2 Jahren
Ursprung
Commit
13d3213316
2 geänderte Dateien mit 85 neuen und 4 gelöschten Zeilen
  1. 81 0
      common/create_user.py
  2. 4 4
      weixinzhishu/weixinzhishu_main/run_weixinzhishu_bot.py

+ 81 - 0
common/create_user.py

@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+# @Author: wangkun
+# @Time: 2023/5/10
+import uuid, requests
+
+
+class Demo:
+    @classmethod
+    def get_default_user(cls):
+        url = "https://api-internal.piaoquantv.com/user-center/info/getDefaultUserInfo"
+        payload = {"params": {"mid": str(uuid.uuid1())}}
+        headers = {
+            'Content-Type': 'application/json'
+        }
+        response = requests.request("POST", url, headers=headers, json=payload).json()
+        return response['data']
+
+    @classmethod
+    def create_uid(cls, user_dict, env):
+        """
+        创建站内虚拟 UID
+        :param user_dict: 字典{'nickName': 用户名, 'avatarUrl': 头像, 'tagName': 站内用户标签}
+        :param env: 环境
+        :return: 站内 UID
+        """
+        if env == 'dev':
+            # 外网
+            url = 'https://videotest.yishihui.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
+            # 内网
+            # url = 'http://videotest-internal.yishihui.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
+        elif env == 'prod':
+            # 外网
+            url = 'https://longvideoapi.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
+            # 内网
+            # url = 'http://longvideoapi-internal.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
+        else:
+            # 外网
+            url = 'https://longvideoapi.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
+            # 内网
+            # url = 'http://longvideoapi-internal.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
+        params = {
+            # 'count': 1,     # (必须)账号个数:传1
+            # 'accountType': 4,   # (必须)账号类型 :传 4 app虚拟账号
+            'recommendStatus': user_dict.get('recommendStatus', -6),
+            'appRecommendStatus': user_dict.get('appRecommendStatus', -6),
+            'pwd': '',  # 密码 默认 12346
+            'nickName': user_dict['nickName'],  # 昵称  默认 vuser......
+            'avatarUrl': user_dict['avatarUrl'],
+            # 头像Url  默认 http://weapppiccdn.yishihui.com/resources/images/pic_normal.png
+            # 'tagName': user_dict['tagName'],  # 多条数据用英文逗号分割
+        }
+        response = requests.post(url=url, params=params)
+        # print(response.text)
+        user_id = response.json()['data']
+        return user_id
+
+    @classmethod
+    def create_user(cls, env):
+        default_user = cls.get_default_user()
+        # 用来创建our_id的信息
+        user_dict = {
+            'recommendStatus': -6,
+            'appRecommendStatus': -6,
+            'nickName': default_user['nickName'],
+            'avatarUrl': default_user['avatarUrl'],
+            # 'tagName': f'{tag1},{tag2},{tag3},{tag4},{tag5}',
+        }
+        our_uid = cls.create_uid(user_dict, env)
+        if env == 'prod':
+            our_user_link = f'https://admin.piaoquantv.com/ums/user/{our_uid}/post'
+        else:
+            our_user_link = f'https://testadmin.piaoquantv.com/ums/user/{our_uid}/post'
+        print(our_uid)
+        print(our_user_link)
+
+
+if __name__ == "__main__":
+    print(uuid.uuid1())
+    # for i in range(10):
+    #     # 正式环境
+    #     Demo.create_user("prod")

+ 4 - 4
weixinzhishu/weixinzhishu_main/run_weixinzhishu_bot.py

@@ -21,13 +21,13 @@ class WeixinzhishuBot:
 
         first_key_time_str = sheet[1][0]
         if first_key_time_str is None:
-            if 14 >= datetime.datetime.now().hour >= 11 and datetime.datetime.now().minute >= 40:
-                Feishu.bot(log_type, crawler, "微信指数 Search_Key is None ~")
-                time.sleep(3600*2)
+            if 13 >= datetime.datetime.now().hour >= 11 and datetime.datetime.now().minute >= 20:
+                # Feishu.bot(log_type, crawler, "微信指数 Search_Key is None ~")
+                time.sleep(60)
 
         first_key_time_stamp = int(time.mktime(time.strptime(first_key_time_str, "%Y-%m-%d %H:%M:%S")))
         if int(time.time()) - first_key_time_stamp >= 60*3:
-            if 14 >= datetime.datetime.now().hour >= 11 and datetime.datetime.now().minute >= 40:
+            if 13 >= datetime.datetime.now().hour >= 11 and datetime.datetime.now().minute >= 20:
                 Feishu.bot(log_type, crawler, "微信指数 Search_Key 过期啦 ~")
                 time.sleep(3600*2)
         else: