import requests import json # url = "http://127.0.0.1:7960/brandcultivation/api/v1/recommend" # payload = { # "city_uuid": "00000000000000000000000011445301", # "product_code": "440298", # "recall_cust_count": 500, # "delivery_count": 5000 # } # headers = {'Content-Type': 'application/json'} # response = requests.post(url, data=json.dumps(payload), headers=headers) # print(response.json()) # 2. 然后调用报告下载接口 download_url = "http://127.0.0.1:7960/brandcultivation/api/v1/download_report" download_payload = { "city_uuid": "00000000000000000000000011445301", "product_code": "440298" } download_headers = {'Content-Type': 'application/json'} print("\n调用报告下载接口...") download_response = requests.get( download_url, params=download_payload, # 注意GET请求使用params而不是data headers=download_headers ) print(json.dumps(download_response.json(), indent=2)) if download_response.json().get("code") == 200: for file_info in download_response.json()["data"]["reportDownloadInfo"]: print(f"\n下载文件: {file_info['filename']}") file_response = requests.get(file_info["download_url"]) with open(file_info["filename"], "wb") as f: f.write(file_response.content) print(f"已保存到: {file_info['filename']}")