Kaynağa Gözat

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

罗俊辉 10 ay önce
ebeveyn
işleme
42c63e4bda

+ 15 - 3
applications/search/hksp_search.py

@@ -14,6 +14,19 @@ from fake_useragent import FakeUserAgent
 from applications.functions.common import sensitive_flag
 
 
+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):
     """
     获取好看视频的视频链接
@@ -76,7 +89,7 @@ def hksp_search(key, sensitive_words):
         'x-requested-with': 'xmlhttprequest',
     }
     # 发送GET请求
-    response = requests.get(url, headers=headers, params=params).json()
+    response = requests.get(url, headers=headers, params=params, proxies=tunnel_proxies()).json()
     try:
         data_list = response['data']['list']
         L = []
@@ -91,8 +104,7 @@ def hksp_search(key, sensitive_words):
                 else:
                     continue
             except Exception as e:
-                print(e)
                 pass
         return L
     except:
-        return []
+        return []

+ 1 - 1
applications/search/xigua_search.py

@@ -237,7 +237,7 @@ def xigua_search_v2(keyword, sensitive_words):
         'cookie': '_tea_utm_cache_2285=undefined;',
         'priority': 'u=1, i',
         'referer': 'https://www.ixigua.com/search/{}'.format(urllib.parse.quote(keyword)),
-        'user-agent': FakeUserAgent().random
+        'user-agent': FakeUserAgent().chrome
     }
     response = requests.request("GET", url, headers=headers, params=params)