add workflow 天润Smart-ccc会话数据,dev

This commit is contained in:
root 2024-12-13 16:56:55 +08:00
parent 6d7788a423
commit cf60e82ea0
1 changed files with 7 additions and 7 deletions

View File

@ -85,10 +85,10 @@ def request_data_signature_get(scrollId,d):
print(f'开始请求会话记录数据')
url='https://api-bj.clink.cn/livechat/copy_chat_records'
if scrollId is None:
param={'Timestamp':current_time_utc,'Expires':86400,'date':formatted2_previous_date(d),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':100}
param={'Timestamp':current_time_utc,'Expires':86400,'date':formatted2_previous_date(d),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':1000}
# param={'Timestamp':current_time_utc,'Expires':86400,'date':'20240801','AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':100}
else:
param={'Timestamp':current_time_utc,'Expires':86400,'date':formatted2_previous_date(d),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':100,'scrollId':scrollId}
param={'Timestamp':current_time_utc,'Expires':86400,'date':formatted2_previous_date(d),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':1000,'scrollId':scrollId}
# param={'Timestamp':current_time_utc,'Expires':86400,'date':'20240801','AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':100,'scrollId':scrollId}
print(f'param: {param}')
url_path = build_query_string(param)
@ -105,7 +105,7 @@ def request_data_signature_get(scrollId,d):
dataReqL=requests.get(url,headers={},params={})
resText = dataReqL.text
i = 0
while 'error' in resText and i < 5:
while 'records' not in resText and i < 5:
print(f'请求会话记录失败,再次请求第{i+1}')
time.sleep(1)
dataReqL=requests.get(url,headers={},params={})
@ -119,7 +119,7 @@ def request_data_signature_get(scrollId,d):
def request_detail_signature_get(id):
print(f'开始请求会话详情数据:{id}')
url='https://api-bj.clink.cn/livechat/list_chat_messages'
param={'Timestamp':current_time_utc,'Expires':86400,'mainUniqueId':id,'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':100}
param={'Timestamp':current_time_utc,'Expires':86400,'mainUniqueId':id,'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':1000}
print(f'param: {param}')
url_path = build_query_string(param)
url_param = url_path
@ -136,7 +136,7 @@ def request_detail_signature_get(id):
resText = dataReqL.text
i = 0
if 'records' not in resText:
while 'error' in resText and i < 5:
while 'records' not in resText and i < 5:
print(f'请求会话详情失败,再次请求第{i+1}')
time.sleep(1)
dataReqL=requests.get(url,headers={},params={})
@ -210,7 +210,7 @@ def fetch_records_all(d):
resL = request_data_signature_get(None,d)
# print(resL)
list = []
if 'error' in resL:
if 'records' not in resL:
error = resL['error']
print(f'请求会话列表失败,失败原因:{error}')
else:
@ -230,7 +230,7 @@ def fetch_records_all(d):
if len(nextList) == 0:
break
list = list + nextList
if len(nextList) < 100:
if len(nextList) < 1000:
break
print(f'records会话记录数为{len(list)}, 共请求{i}次会话')
return list