{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "686215f8", "metadata": {}, "outputs": [], "source": [ "from requests import get,post\n", "import time\n", "ip = \"http://band.hxzhxy.cn\"\n", "param = {\n", " \"username\": \"zhongwei\",\n", " \"password\": \"123456a\",\n", " \"client_id\": \"client\",\n", " \"grant_type\": \"password\",\n", " \"client_secret\": \"123456\",\n", "}\n", "data = get(url=f\"http://band.hxzhxy.cn/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456\").json()\n", "token = data[\"access_token\"]\n", "header = {\n", " \"content-type\": \"application/json\",\n", " \"authorization\": f\"Bearer {token}\",\n", "}" ] }, { "cell_type": "code", "execution_count": 2, "id": "63e34092", "metadata": {}, "outputs": [], "source": [ "ids = [36, 56,95,96,146,223,234,331,392,397,398,406,416,419,420]" ] }, { "cell_type": "code", "execution_count": 4, "id": "775850cb", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'36&ids=56&ids=95&ids=96&ids=146&ids=223&ids=234&ids=331&ids=392&ids=397&ids=398&ids=406&ids=416&ids=419&ids=420'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"&ids=\".join([str(i) for i in ids])" ] }, { "cell_type": "code", "execution_count": 5, "id": "6b68dc63", "metadata": {}, "outputs": [], "source": [ "url = 'https://www.hxzhxy.cn/hxyd-api/uc/role/grant/235?ids=36&ids=56&ids=95&ids=96&ids=146&ids=223&ids=234&ids=331&ids=392&ids=397&ids=398&ids=406&ids=416&ids=419&ids=420&access_token=a0db0a6f-0b16-4948-8d8b-4a0b6ab15f90'" ] }, { "cell_type": "code", "execution_count": null, "id": "3140ac56", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'success': True, 'msg': '操作成功', 'code': 0, 'data': None}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" }, { "ename": "", "evalue": "", "output_type": "error", "traceback": [ "\u001b[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。\n", "\u001b[1;31m请查看单元格中的代码,以确定故障的可能原因。\n", "\u001b[1;31m单击此处了解详细信息。\n", "\u001b[1;31m有关更多详细信息,请查看 Jupyter log。" ] } ], "source": [ "post(url=url,headers=header).json()" ] } ], "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.12.4" } }, "nbformat": 4, "nbformat_minor": 5 }