topic-clustering-global-dashboard / service_cache_Thien.py
cuongnguyen910's picture
Upload folder using huggingface_hub
5120311 verified
import requests
def get_data_sorl(query, keywords, start_time, end_time, max_posts = 100):
start_time = start_time.strip()
end_time = end_time.strip()
json_data = {
'category_ids': [],
'text_query': query,
'max_posts': max_posts,
'top': 50,
'lang': 'vi',
'source_tagids': [],
'cee': True,
'keywords': keywords,
'start_time': start_time.replace(' ', 'T'),
'end_time': end_time.replace(' ', 'T'),
}
res = []
request_search_qna = 'http://10.9.3.241:2436/service_get_data_sorl'
try:
response = requests.post('http://10.9.3.241:2436/service_get_data_sorl', json=json_data)
if response.status_code == 200:
res = response.json()['results']
else:
print("Error search QnA: ", response.text)
except Exception as ex:
print("Error search QnA: ", ex)
json_data = {
'category_ids': [],
'text_query': query,
'max_posts': 100,
'top': 50,
'lang': 'vi',
'source_tagids': [],
'cee': False,
'keywords': keywords,
'start_time': start_time,
'end_time': end_time,
}
res_2 = []
try:
response = requests.post('http://10.9.3.241:2436/service_get_data_sorl', json=json_data)
if response.status_code == 200:
res_2 = response.json()['results']
else:
print("Error search QnA: ", response.text)
except Exception as ex:
print("Error search QnA: ", ex)
res.extend(res_2)
return res