{ "cells": [ { "cell_type": "code", "execution_count": 25, "id": "31c0e11d-c87a-4e95-92a0-d1d09625e255", "metadata": {}, "outputs": [], "source": [ "from config_jingbo import *\n", "import requests\n", "import json\n", "import datetime" ] }, { "cell_type": "code", "execution_count": 26, "id": "83c81b9e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'http://192.168.100.53:8080/jingbo-dev/api/server/login'" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_pushreport_url\n" ] }, { "cell_type": "code", "execution_count": null, "id": "a058f507", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 27, "id": "2b330ee3-c006-4ab1-8558-59c51ac8d86f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': {'account': 'api_test',\n", " 'password': 'ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=',\n", " 'tenantHashCode': '8a4577dbd919675758d57999a1e891fe',\n", " 'terminal': 'API'},\n", " 'funcModule': 'API',\n", " 'funcOperation': '获取token'}" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_data" ] }, { "cell_type": "code", "execution_count": 28, "id": "dcb6100a-ed2b-4077-a1a9-361c6cb565f9", "metadata": {}, "outputs": [], "source": [ "\n", "def get_head_auth_report():\n", " login_res = requests.post(url=login_pushreport_url, json=login_data, timeout=(3, 5))\n", " text = json.loads(login_res.text)\n", " print(text)\n", " if text[\"status\"]:\n", " token = text[\"data\"][\"accessToken\"]\n", " return token\n" ] }, { "cell_type": "code", "execution_count": 29, "id": "22c0c7c4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'confirmFlg': False, 'data': {'accessToken': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzUxNDkzMzYsImp0aSI6IjczYzJkOGJjYzQ2NzQwYjNiYWQxZmI3NjMzODM4YTcxIn0.zLVuyCEbg-x9lRXuJDYbdiwzo_nhEQGCCInnJKfQcd8', 'md5Token': '39413fe9e3e93f717d8d2713c4487172'}, 'status': True}\n" ] } ], "source": [ "token = get_head_auth_report()" ] }, { "cell_type": "code", "execution_count": 30, "id": "12077ead", "metadata": {}, "outputs": [], "source": [ "# token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzE5NTkzNjUsImp0aSI6IjRiMjcwNTgzN2YyZDQxOWM4MzQ3NjI2NDQwZDlhZGQzIn0.PPgnoiJt412dJiceqVW8w7qkJFY4s-VqU9z6ZIkpqho'" ] }, { "cell_type": "code", "execution_count": 31, "id": "a7ae21d1", "metadata": {}, "outputs": [], "source": [ "# def upload_warning_data(warning_data):\n", "# token = get_head_auth_report()\n", "# warning_data = warning_data\n", "# headers = {\"Authorization\": token}\n", "# logger.info(\"预警上传中...\")\n", "# logger.info(f\"token:{token}\")\n", "# logger.info(f\"warning_data:{warning_data}\" )\n", "# upload_res = requests.post(url=upload_warning_url, headers=headers, json=warning_data, timeout=(3, 15))\n", "# if upload_res:\n", "# return upload_res\n", "# else:\n", "# logger.info(\"预警上传失败\")\n", "# return None\n", "\n", "\n", "# logger.info(f'上传预警信息')\n", "# try:\n", "# warning_date = datetime.datetime.now().strftime('%Y-%m-%d')\n", "# content = f'{warning_date}有2887个停更'\n", "# warning_data['data']['WARNING_DATE'] = warning_date\n", "# warning_data['data']['WARNING_CONTENT'] = content\n", "# upload_warning_data(warning_data)\n", "# logger.info(f'上传预警信息成功')\n", "# except Exception as e:\n", "# logger.error(f'上传预警信息失败:{e}')" ] }, { "cell_type": "code", "execution_count": null, "id": "54942e1a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\"confirmFlg\":false,\"data\":[],\"status\":true}\n" ] } ], "source": [ "query_data_list_item_nos_data = {\n", " \"funcModule\":'数据项编码集合',\n", " \"funcOperation\":'数据项编码集合',\n", " \"data\":{\n", " \"dataItemNoList\":['EXCHANGE|RATE|MIDDLE_PRICE'],\n", " \"dateEnd\":'20240101',\n", " \"dateStart\":'20241024'\n", " \n", " }\n", "}\n", "\n", "headers = {\"Authorization\": token}\n", "items_res = requests.post(url=query_data_list_item_nos_url, headers=headers, json=query_data_list_item_nos_data, timeout=(3, 35))\n", "print(items_res.text)" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }