{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "53568812",
   "metadata": {},
   "outputs": [],
   "source": [
    "from requests import get,post\n",
    "import time\n",
    "ip = \"http://band.hxzhxy.cn\"\n",
    "param = {\n",
    "    \"username\": \"tangchao\",\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\",params=param).json()\n",
    "token = data[\"access_token\"]\n",
    "header = {\n",
    "    \"content-type\": \"application/json\",\n",
    "    \"authorization\": f\"Bearer {token}\",\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "dd37d282",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = get(\"https://www.hxzhxy.cn/hxyd-api/uc/student/pageInfo?teamId=119&gradeId=127&classId=483&name=&type=0&pageSize=50&pageNumber=0&orderDirection=asc&access_token=0cfa97d4-2b01-4be4-a7f7-13179d149e56\").json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "eaa3dadd",
   "metadata": {},
   "outputs": [],
   "source": [
    "serialNo = []\n",
    "for item in data[\"data\"][\"content\"]:\n",
    "    serialNo.append(item[\"seralNo\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "aedb175d",
   "metadata": {},
   "outputs": [],
   "source": [
    "serialNos = \",\".join(serialNo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "fff85f0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"success\":true,\"msg\":\"操作成功\",\"code\":0,\"data\":null}\n"
     ]
    }
   ],
   "source": [
    "result  =post(\"https://band.hxzhxy.cn/door/accredit/sendNews\",json={\"startTime\":\"25083115\",\"endTime\":\"28052815\",\"adminType\":\"55\",\"type\":\"01\",\"time\":[1756625633772,1843112033772],\"accountIp\":\"183.220.92.52\",\"accountName\":\"183.220.92.52\",\"lockNo\":\"181681774465\",\"serialNo\":serialNos,\"addAdminBand\":\"\",\"addUserBand\":\"\",\"removeBand\":\"\",\"doorAccreditIds\":\"\"},headers=header).text\n",
    "print(result)"
   ]
  }
 ],
 "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
}
