Browse Source

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

罗俊辉 1 year ago
parent
commit
724fdaf741
1 changed files with 23 additions and 1 deletions
  1. 23 1
      applications/search/hksp_search.py

+ 23 - 1
applications/search/hksp_search.py

@@ -9,6 +9,18 @@ import hashlib
 
 from applications.functions.common import MySQLServer
 
+def tunnel_proxies():
+    # 隧道域名:端口号
+    tunnel = "q796.kdltps.com:15818"
+    # 用户名密码方式
+    username = "t17772369458618"
+    password = "5zqcjkmy"
+    proxies = {
+        "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel},
+        "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel}
+    }
+    return proxies
+
 
 def get_video_detail(video_id):
     """
@@ -36,7 +48,13 @@ def get_video_detail(video_id):
         'Referer': 'https://haokan.baidu.com',
         'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
     }
-    response = requests.request("GET", url, headers=headers, params=params).json()
+    response = requests.request(
+        "GET",
+        url,
+        headers=headers,
+        params=params,
+        proxies=tunnel_proxies()
+    ).json()
     return response['data']['apiData']['curVideoMeta']
 
 
@@ -98,3 +116,7 @@ def hksp_search(key):
         except:
             pass
     return L
+
+
+L = hksp_search("【头次】对拜登背后放冷枪,越南干得漂亮,俄罗斯立功,中国成赢家!")
+print(L)