|
|
@ -195,6 +195,16 @@ def send_request(request): |
|
|
|
response = requests.Session().send(req) |
|
|
|
response = requests.Session().send(req) |
|
|
|
print('response', response.content) |
|
|
|
print('response', response.content) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 处理xml数据 |
|
|
|
|
|
|
|
handled_data = '' |
|
|
|
|
|
|
|
response_data = '' |
|
|
|
|
|
|
|
if resp_format == 'json': |
|
|
|
|
|
|
|
response_data = response.text |
|
|
|
|
|
|
|
handled_data = json.loads(response.text) |
|
|
|
|
|
|
|
if resp_format == 'xml': |
|
|
|
|
|
|
|
response_data = format_xml(re.sub(r'>\n?\s+?<', r'>\n<', response.text)) |
|
|
|
|
|
|
|
handled_data = HandleXmlResp(response.text).format_xml() |
|
|
|
|
|
|
|
|
|
|
|
# 记录Redis |
|
|
|
# 记录Redis |
|
|
|
if redis_conn.exists(redis_key_api): |
|
|
|
if redis_conn.exists(redis_key_api): |
|
|
|
redis_conn.delete(redis_key_api) |
|
|
|
redis_conn.delete(redis_key_api) |
|
|
@ -203,7 +213,8 @@ def send_request(request): |
|
|
|
'member_type': member_type, |
|
|
|
'member_type': member_type, |
|
|
|
'format': resp_format, |
|
|
|
'format': resp_format, |
|
|
|
'params': params, |
|
|
|
'params': params, |
|
|
|
'response_data': response.text |
|
|
|
'response_data': response.text, |
|
|
|
|
|
|
|
'handled_data': handled_data, |
|
|
|
} |
|
|
|
} |
|
|
|
print(data) |
|
|
|
print(data) |
|
|
|
redis_conn.set(redis_key_api, json.dumps(data), 10 * 60 * 60) |
|
|
|
redis_conn.set(redis_key_api, json.dumps(data), 10 * 60 * 60) |
|
|
@ -218,17 +229,8 @@ def send_request(request): |
|
|
|
} |
|
|
|
} |
|
|
|
print(db_data) |
|
|
|
print(db_data) |
|
|
|
EcRequestLog.objects.create(**db_data) |
|
|
|
EcRequestLog.objects.create(**db_data) |
|
|
|
# 处理xml数据 |
|
|
|
|
|
|
|
handled_data = '' |
|
|
|
return JsonResponse({'format': resp_format, 'data': response_data, 'handled': json.dumps(handled_data)}) |
|
|
|
_data = '' |
|
|
|
|
|
|
|
if resp_format == 'json': |
|
|
|
|
|
|
|
_data = response.text |
|
|
|
|
|
|
|
handled_data = json.loads(response.text) |
|
|
|
|
|
|
|
if resp_format == 'xml': |
|
|
|
|
|
|
|
_data = format_xml(re.sub(r'>\n?\s+?<', r'>\n<', response.text)) |
|
|
|
|
|
|
|
print('---format_xml-----', _data) |
|
|
|
|
|
|
|
handled_data = HandleXmlResp(response.text).format_xml() |
|
|
|
|
|
|
|
return JsonResponse({'format': resp_format, 'data': _data, 'handled': json.dumps(handled_data)}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 对外接口,用于收集用户选择的数据,例如场次,卖品等,以便后续接口直接调用 |
|
|
|
# 对外接口,用于收集用户选择的数据,例如场次,卖品等,以便后续接口直接调用 |
|
|
|