Explorar el Código

2024-06-04
取消微信搜索接口服务

罗俊辉 hace 11 meses
padre
commit
ba31013c94
Se han modificado 2 ficheros con 16 adiciones y 13 borrados
  1. 2 1
      applications/schedule/search_schedule.py
  2. 14 12
      applications/search/weixin_search.py

+ 2 - 1
applications/schedule/search_schedule.py

@@ -154,7 +154,8 @@ class SearchMethod(object):
         一共需要返回三条视频
         :return:
         """
-        wx_result = wx_search(keys=text, sensitive_words=cls.s_words)
+        # wx_result = wx_search(keys=text, sensitive_words=cls.s_words)
+        wx_result = []
         if wx_result:
             return {"platform": "wx_search", "result": wx_result[0]}
         else:

+ 14 - 12
applications/search/weixin_search.py

@@ -24,22 +24,24 @@ def wx_search(keys, sensitive_words):
         'Content-Type': 'application/json'
     }
     response = requests.request("POST", url, headers=headers, data=payload).json()
+    print(response)
     if response['msg'] == '未知错误':
         return []
     else:
         L = []
         if response['data']:
             video_list = response['data']['data']
-            for video in video_list:
-                try:
-                    video_info = video['items'][0]
-                    title = video_info['title']
-                    duration_str = video_info['duration']
-                    dr = int(duration_str.split(":")[0].strip()) + int(duration_str.split(":")[1].strip())
-                    if sensitive_flag(sensitive_words, title) and dr <= 300:
-                        L.append(video_info)
-                    else:
-                        continue
-                except:
-                    pass
+            if video_list:
+                for video in video_list:
+                    try:
+                        video_info = video['items'][0]
+                        title = video_info['title']
+                        duration_str = video_info['duration']
+                        dr = int(duration_str.split(":")[0].strip()) + int(duration_str.split(":")[1].strip())
+                        if sensitive_flag(sensitive_words, title) and dr <= 300:
+                            L.append(video_info)
+                        else:
+                            continue
+                    except:
+                        pass
         return L