|
@@ -6,23 +6,25 @@ Created on 2023-10-10
|
|
|
---------
|
|
|
@author: Lzz
|
|
|
"""
|
|
|
+from requests.auth import HTTPBasicAuth
|
|
|
import requests
|
|
|
import json
|
|
|
|
|
|
|
|
|
def get_should(title):
|
|
|
|
|
|
- url = "http://172.17.145.178:9200/_analyze" # 线上
|
|
|
- # url = "http://192.168.3.241:9200/_analyze" # 本地
|
|
|
+ url = "http://172.17.4.184:19905/_analyze" # 线上
|
|
|
+ username = "jybid"
|
|
|
+ password = "Top2023_JEB01i@31"
|
|
|
|
|
|
headers = {"Content-Type": "application/json"}
|
|
|
-
|
|
|
+ auth = HTTPBasicAuth(username, password)
|
|
|
data = {
|
|
|
"analyzer": "ik_smart",
|
|
|
"text": title
|
|
|
}
|
|
|
|
|
|
- res = requests.post(url, headers=headers, json=data, timeout=10)
|
|
|
+ res = requests.post(url, headers=headers, auth=auth, json=data, timeout=10)
|
|
|
|
|
|
try:
|
|
|
res_text = json.loads(res.text).get('tokens') or [{"token":title}]
|
|
@@ -42,4 +44,5 @@ def get_should(title):
|
|
|
}
|
|
|
should_list.append(single_dict)
|
|
|
|
|
|
- return should_list
|
|
|
+ return should_list
|
|
|
+
|