{ "cells": [ { "cell_type": "code", "execution_count": 6, "id": "31c0e11d-c87a-4e95-92a0-d1d09625e255", "metadata": {}, "outputs": [], "source": [ "from config_jingbo import *\n", "import requests\n", "import json" ] }, { "cell_type": "code", "execution_count": 7, "id": "83c81b9e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'http://192.168.100.53:8080/jingbo-dev/api/server/login'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_pushreport_url\n" ] }, { "cell_type": "code", "execution_count": 8, "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": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_data" ] }, { "cell_type": "code", "execution_count": null, "id": "dcb6100a-ed2b-4077-a1a9-361c6cb565f9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'confirmFlg': False, 'data': {'accessToken': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzE5NDMzODgsImp0aSI6ImMwMTY4NWI1NTFlMzQyNGQ5M2JkZDIyYmE4YzI3YjY5In0.cj5Py63Hl0VML75Yy5VyFz4le-aM3VtFPXjjuwS8Y3w', 'md5Token': 'bd259af3a6d7e158204664387e18c4f5'}, 'status': True}\n" ] } ], "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": null, "id": "22c0c7c4", "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'get_head_auth_report' is not defined", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[10], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m get_head_auth_report()\n", "\u001b[1;31mNameError\u001b[0m: name 'get_head_auth_report' is not defined" ] } ], "source": [ "token = get_head_auth_report()" ] }, { "cell_type": "code", "execution_count": null, "id": "12077ead", "metadata": {}, "outputs": [], "source": [ "token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzE5NDQ1MjMsImp0aSI6IjMxOTFlYTFmMDljOTQ3MjQ5OGIxYmEzMWZiYzUyNWE5In0.XEvtFDbN6Qd9ibTEzLWykcDSgiQQOgBro6vTzXiwbgQ'" ] }, { "cell_type": "code", "execution_count": null, "id": "a7ae21d1", "metadata": {}, "outputs": [], "source": [ "warning_data = {'funcModule': '原油特征停更预警', \n", " 'funcOperation': '原油特征停更预警', \n", " 'data': {'WARNING_TYPE_NAME': '日度数据', \n", " 'WARNING_CONTENT': ''' feature last_update_time update_period warning_date\\n 美国:东海岸地区:炼油厂的投入与使用情况:开工率:当周值 2024-06-14 7.0 2024-06-29\\n 美国:炼油厂的投入与 使用情况:开工率:当周值 2024-06-14 7.0 2024-06-29\\n 美国:洛基山地区:炼油厂的投入与使用情况:开工率:当周值 2024-06-14 7.0 2024-06-29\\n \n", " 美国:墨西哥湾沿岸:炼油厂的投入与使用情况:开工率:当周值 2024-06-14 7.0 2024-06-29\\n 美国:西海岸地区:炼油厂的投入与使用情况:开工率:当周值 2024-06-14 7.0 2024-06-29\\n 美国:中西部地区:炼油厂的投入与使用情况:开工率:当周值 2024-06-14 7.0 2024-06-29\\n 中国航班执行数 2024-04-10 1.0 2024-04-13\\n 美国汽油产量占比 2024-10-04 7.0 2024-10-19\\n 美国柴油产量占比 2024-10-04 7.0 2024-10-19\\n 西北欧即期Brent 211利润 2018-10-24 1.0 2018-10-27\\n 美国RBOB期货2309月份合约价格 2023-08-31 1.0 2023-09-03\\nPVM Dubai EFS/Swap vs ICE First Month Brent 2023-01-03 1.0 2023-01-06\\n Ebob连1合约 2024-02-28 1.0 2024-03-02\\n Brent/迪拜原油升贴水 2022-11-16 1.0 2022-11-19\\n W-B活跃合约价差 2022-01-31 1.0 2022-02-03\\n B-W活跃合约价差 2022-01-31 1.0 2022-02-03\\n Brent c2-c3 (结算B) 2024-10-31 1.0 2024-11-03\\n WTI c2-c3 (结算B) 2024-10-31 1.0 2024-11-03\\n Kpler-海运在途原油 2024-08-20 1.0 2024-08-23\\n 全球原油库存(剔除富查伊拉) 2024-07-21 7.0 2024-08-05\\n 原油:山东港口:库存:新口径(周)超季节性/3年 2024-05-24 7.0 2024-06-08\\n 原油:港口库存:中国(周) 2023-08-04 7.0 2023-08-19\\n 原油:山东港口:库存:新口径(周) 2024-05-24 7.0 2024-06-08\\n 美国墨西哥湾87#汽油现货价格 2024-01-31 1.0 2024-02-03\\n 欧洲汽油裂解 2024-11-01 1.0 2024-11-04\\n Brent c1 02:30收盘价滞后1天 2024-10-30 1.0 2024-11-02\\n Brent c2 02:30收盘价滞后1天 2024-10-30 1.0 2024-11-02\\n EFS c1 02:30收盘价滞后1天 2024-10-30 1.0 2024-11-02\\n EFS c2 02:30收盘价滞后1天 2024-10-30 1.0 2024-11-02\\n 原油:开工率:东北地区:独立炼厂(周) 2023-03-31 7.0 2023-04-15\\n 美国墨西哥湾原油钻机数 2024-09-27 7.0 2024-10-12\\n Kpler-美国原油净进口(周度) 2024-08-25 7.0 2024-09-09\\n 中东-也门周度原油海运出口 2023-08-27 21.0 2023-10-09\\n 中东-巴林周度原油海运出口 2024-04-28 7.0 2024-05-13' ''', \n", " 'WARNING_DATE': '2024-11-14'}}" ] }, { "cell_type": "code", "execution_count": null, "id": "3e1a9e67", "metadata": {}, "outputs": [], "source": [ "# def upload_warning_data(token, warning_data):\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", "print(upload_res)\n", " # if upload_res:\n", " # return upload_res\n", " # else:\n", " # logger.info(\"预警上传失败\")\n", " # return None" ] } ], "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 }