add workflow 天润Smart-ccc会话数据,dev
This commit is contained in:
parent
263c706eac
commit
8c3bc9dac9
|
@ -68,10 +68,13 @@ def build_query_string(params):
|
|||
) for k, v in sorted_params.items())
|
||||
return query_string
|
||||
|
||||
def request_data_signature_get():
|
||||
def request_data_signature_get(scrollId):
|
||||
print(f'开始请求会话记录数据')
|
||||
url='https://api-bj.clink.cn/livechat/copy_chat_records'
|
||||
param={'Timestamp':current_time_utc,'Expires':86400,'date':formatted2_previous_date(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||
if scrollId is None:
|
||||
param={'Timestamp':current_time_utc,'Expires':86400,'date':formatted2_previous_date(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':100}
|
||||
else:
|
||||
param={'Timestamp':current_time_utc,'Expires':86400,'date':formatted2_previous_date(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':100,'scrollId':scrollId}
|
||||
print(f'param: {param}')
|
||||
url_path = build_query_string(param)
|
||||
url_param = url_path
|
||||
|
@ -96,8 +99,6 @@ def request_data_signature_get():
|
|||
resD=json.loads(resText)
|
||||
return resD
|
||||
|
||||
|
||||
|
||||
def request_detail_signature_get(id):
|
||||
print(f'开始请求会话详情数据:{id}')
|
||||
url='https://api-bj.clink.cn/livechat/list_chat_messages'
|
||||
|
@ -185,11 +186,26 @@ if __name__ == "__main__":
|
|||
error = resL['error']
|
||||
print(f'请求会话列表失败,失败原因:{error}')
|
||||
else:
|
||||
dataList = resL['records']
|
||||
load_data_to_db(dataList)
|
||||
list = resL['records']
|
||||
scrollId = resL['scrollId']
|
||||
nextList = []
|
||||
while scrollId is not None:
|
||||
resN = request_data_signature_get(scrollId)
|
||||
if 'error' in resN:
|
||||
error = resL['error']
|
||||
print(f'请求会话列表失败,失败原因:{error}')
|
||||
break
|
||||
nextList = resN['records']
|
||||
scrollId = resN['scrollId']
|
||||
if len(nextList) == 0:
|
||||
break
|
||||
list = list + nextList
|
||||
if len(nextList) < 100:
|
||||
break
|
||||
load_data_to_db(list)
|
||||
detailDataList = []
|
||||
ids = []
|
||||
for data in dataList:
|
||||
for data in list:
|
||||
try:
|
||||
id = data['mainUniqueId']
|
||||
resD = request_detail_signature_get(id)
|
||||
|
@ -197,6 +213,7 @@ if __name__ == "__main__":
|
|||
if 'records' in resD:
|
||||
ids.append(id)
|
||||
dataList = resD['records']
|
||||
|
||||
# detailDataList.append(dataList)
|
||||
detailDataList = detailDataList+dataList
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue