first commit

This commit is contained in:
2025-10-20 12:32:18 +08:00
commit 2cfd7c5a08
121 changed files with 254585 additions and 0 deletions
+205
View File
@@ -0,0 +1,205 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "137d8688",
"metadata": {},
"outputs": [],
"source": [
"from requests import get, post,put"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ebfc2997",
"metadata": {},
"outputs": [],
"source": [
"from requests import sessions\n",
"\n",
"\n",
"\n",
"\n",
"def print_url_hook(response, *args, **kwargs):\n",
" print(f\"Request URL: {response.request.url}\")\n",
" print(f\"Request Headers: {response.request.headers}\")\n",
" print(f\"Request Body: {response.request.body}\")\n",
"# 定义一个钩子函数,用于在收到响应后打印出响应的详细信息\n",
"def print_response_hook(response, *args, **kwargs):\n",
" print(f\"Response URL: {response.url}\")\n",
" print(f\"Response Status Code: {response.status_code}\")\n",
" print(f\"Response Headers: {response.headers}\")\n",
" print(f\"Response Body: {response.text}\")\n",
" # response._content = b'1.cpp'\n",
" print(f\"Response Body: {response.text}\")\n",
"\n",
"sessions = sessions.Session()\n",
"# 注册钩子函数\n",
"sessions.hooks['response'].append(print_url_hook)\n",
"sessions.hooks['response'].append(print_response_hook)"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "eb844e83",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Request URL: http://192.168.0.244:8100/oauth/token?client_id=client&grant_type=client_credentials&client_secret=123456\n",
"Request Headers: {'User-Agent': 'python-requests/2.32.2', 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Accept': '*/*', 'Connection': 'keep-alive'}\n",
"Request Body: None\n",
"Response URL: http://192.168.0.244:8100/oauth/token?client_id=client&grant_type=client_credentials&client_secret=123456\n",
"Response Status Code: 200\n",
"Response Headers: {'Cache-Control': 'no-store', 'Pragma': 'no-cache', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'X-Frame-Options': 'DENY', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Date': 'Fri, 23 May 2025 07:07:32 GMT'}\n",
"Response Body: {\"access_token\":\"86878c6c-1151-4db7-93bb-71d9b1c07be9\",\"token_type\":\"bearer\",\"expires_in\":86031,\"scope\":\"select\"}\n",
"Response Body: {\"access_token\":\"86878c6c-1151-4db7-93bb-71d9b1c07be9\",\"token_type\":\"bearer\",\"expires_in\":86031,\"scope\":\"select\"}\n"
]
}
],
"source": [
"param = {\n",
" \"client_id\": \"client\",\n",
" \"grant_type\": \"client_credentials\",\n",
" \"client_secret\": \"123456\",\n",
"}\n",
"# ip = \"https://band.hxzhxy.cn\"\n",
"ip = \"http://192.168.0.244:8100\"\n",
"data = sessions.get(url=f\"{ip}/oauth/token\", params=param)\n",
"header = {\"Authorization\": f\"Bearer {data.json()['access_token']}\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7b54b187",
"metadata": {},
"outputs": [],
"source": [
"sessions.get(\"http://192.168.0.244:8100/home/screen/school\",headers=header)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3624b16d",
"metadata": {},
"outputs": [],
"source": [
"get(\"http://192.168.0.244:8080/home/screen/electric\",headers=header,params={\"access_token\":token})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7a90a2ff",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "b7892f11",
"metadata": {},
"outputs": [],
"source": [
"sessions.get(\"http://192.168.0.244:8080/home/screen/electric\",headers=header,params={\"access_token\":token})"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "9a05cd98",
"metadata": {},
"outputs": [],
"source": [
"file = None\n",
"with open(\"screenshot.png\",\"rb\") as f:\n",
" file = f.read()"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "8a778b76",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"252920"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(file)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "cdfb1954",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'success': True,\n",
" 'msg': 'http://192.168.0.244:9000/test-iot-school/2025-05-23/2a9ad5a85be8459aa58af3d9c6274818.jpg',\n",
" 'code': 0,\n",
" 'data': None}"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"post(f\"{ip}/school/device/content/upload\",headers=header,files={\"file\":(\n",
" \"test.jpg\",\n",
" file\n",
")},proxies={\"http\":\"http://192.168.0.222:8080\"}).json()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1bd04d34",
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}