Browse Source

2024-05-13
多平台搜索上线(微信, 百度, 西瓜)
弃用 search_keys, theme
搜索结果过pq敏感词策略

罗俊辉 1 year ago
parent
commit
84df5cf56c
1 changed files with 17 additions and 18 deletions
  1. 17 18
      applications/search/hksp_search.py

+ 17 - 18
applications/search/hksp_search.py

@@ -9,6 +9,7 @@ import hashlib
 
 from applications.functions.common import MySQLServer
 
+
 def tunnel_proxies():
     # 隧道域名:端口号
     tunnel = "q796.kdltps.com:15818"
@@ -101,22 +102,20 @@ def hksp_search(key):
     }
     # 发送GET请求
     response = requests.get(url, headers=headers, params=params).json()
-    print(response)
-    data_list = response['data']['list']
-
-    L = []
-    for data in data_list:
-        try:
-            video_id = data['vid']
-            res = get_video_detail(video_id)
-            if sensitive_flag(sensitive_words, ['title']) and int(res['duration']) <= 300:
-                L.append(res)
-            else:
-                continue
-        except:
-            pass
-    return L
-
+    try:
+        data_list = response['data']['list']
+        L = []
+        for data in data_list:
+            try:
+                video_id = data['vid']
+                res = get_video_detail(video_id)
+                if sensitive_flag(sensitive_words, ['title']) and int(res['duration']) <= 300:
+                    L.append(res)
+                else:
+                    continue
+            except:
+                pass
+        return L
+    except:
+        return []
 
-L = hksp_search("【头次】对拜登背后放冷枪,越南干得漂亮,俄罗斯立功,中国成赢家!")
-print(L)