File size: 1,846 Bytes
5120311 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
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
|