chore: 批量新增各类工具脚本与配置文件
1. 新增音频录制、下载、上传相关脚本 2. 新增数据库操作、API调用工具 3. 新增Excel数据处理脚本 4. 新增弱密码检测脚本
This commit is contained in:
+29
-36
@@ -1,42 +1,35 @@
|
||||
from requests import get, post, put, delete
|
||||
import random
|
||||
from requests import get, post
|
||||
import time
|
||||
|
||||
ip = "http://192.168.0.209:8100"
|
||||
param = {
|
||||
"username": "zhongwei",
|
||||
"password": "123456a",
|
||||
"client_id": "client",
|
||||
"grant_type": "password",
|
||||
"client_secret": "123456",
|
||||
}
|
||||
data = get(url=f"{ip}/oauth/token", params=param).json()
|
||||
token = data["access_token"]
|
||||
header = {
|
||||
"content-type": "application/json",
|
||||
"authorization": f"Bearer {token}",
|
||||
}
|
||||
teamId = 110
|
||||
year = 2026
|
||||
month = 3
|
||||
|
||||
# v1.jinrishici.com/all.json
|
||||
def apiSentence():
|
||||
data = get("https://v1.hitokoto.cn").json()
|
||||
return data
|
||||
data1 = get(f"{ip}/classAttend/screen/summary", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
|
||||
print("summary:", data1, end="\n\n")
|
||||
|
||||
data2 = get(f"{ip}/classAttend/screen/dailyTrend", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
|
||||
print("dailyTrend:", data2, end="\n\n")
|
||||
|
||||
def cat():
|
||||
data = get("https://api.thecatapi.com/v1/images/search?size=full").json()
|
||||
result = data[0]["url"]
|
||||
return result
|
||||
data3 = get(f"{ip}/classAttend/screen/statusPie", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
|
||||
print("statusPie:", data3, end="\n\n")
|
||||
|
||||
data4 = get(f"{ip}/classAttend/screen/gradeRanking", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
|
||||
print("gradeRanking:", data4, end="\n\n")
|
||||
|
||||
def dog():
|
||||
data = get("https://api.thedogapi.com/v1/images/search?size=full").json()
|
||||
result = data[0]["url"]
|
||||
return result
|
||||
|
||||
|
||||
def pic():
|
||||
data = get("https://api.vvhan.com/api/bing?type=json&rand=sj").json()
|
||||
result = data["data"]["url"]
|
||||
return result
|
||||
|
||||
|
||||
def randomPic():
|
||||
func = random.choice([cat])
|
||||
data = func()
|
||||
return data
|
||||
|
||||
|
||||
def getEmoji():
|
||||
data = get("https://api.vvhan.com/api/emoji?type=json").json()
|
||||
return data
|
||||
|
||||
|
||||
def getShi():
|
||||
data = post("http://v1.jinrishici.com/all.json").json()
|
||||
return data
|
||||
data5 = get(f"{ip}/classAttend/screen/studentRanking", headers=header, params={"teamId": teamId, "year": year, "month": month}).text
|
||||
print("studentRanking:", data5, end="\n\n")
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
from requests import get,post
|
||||
import time
|
||||
ip = "http://192.168.0.209:8100"
|
||||
param = {
|
||||
"username": "zhongwei",
|
||||
"password": "123456a",
|
||||
"client_id": "client",
|
||||
"grant_type": "password",
|
||||
"client_secret": "123456",
|
||||
}
|
||||
data = get(url=f"{ip}/oauth/token",params=param).json()
|
||||
token = data["access_token"]
|
||||
header = {
|
||||
"content-type": "application/json",
|
||||
"authorization": f"Bearer {token}",
|
||||
}
|
||||
teamId=110
|
||||
month=5
|
||||
data1= get(f"{ip}/counseling/screen/stats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
|
||||
print(data1,end="\n\n")
|
||||
|
||||
data2=get(f"{ip}/counseling/screen/trend",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
|
||||
print(data2,end="\n\n")
|
||||
|
||||
data3=get(f"{ip}/counseling/screen/statusDistribution",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
|
||||
print(data3,end="\n\n")
|
||||
|
||||
data4=get(f"{ip}/counseling/screen/gradeStats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
|
||||
print(data4,end="\n\n")
|
||||
|
||||
data5=get(f"{ip}/counseling/screen/projectStats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
|
||||
print(data5,end="\n\n")
|
||||
|
||||
data6=get(f"{ip}/counseling/screen/completionStats",headers=header,params={"teamId":teamId,"year":2026,"month":month}).text
|
||||
print(data6,end="\n\n")
|
||||
+45
-53
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
|
||||
from requests import post
|
||||
tem = post("http://11.1.1.106:8082/api",json={
|
||||
"service_name": "operate_plate",
|
||||
"data": [
|
||||
{
|
||||
"departName": "百仁",
|
||||
"authType": 30000,
|
||||
"plateNumber": "鄂A1234569",
|
||||
"personName": "夏天乐测试",
|
||||
"plateIdStr": "test-plate-id-001",
|
||||
"opType": 1,
|
||||
"beginTime": "2026-05-18 17:53:44",
|
||||
"endTime": "2027-05-18 17:53:44"
|
||||
}
|
||||
]
|
||||
}).text
|
||||
print(tem)
|
||||
@@ -0,0 +1,288 @@
|
||||
from requests import get, post
|
||||
from faker import Faker
|
||||
import random
|
||||
import time
|
||||
import uuid
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
fake = Faker('zh_CN')
|
||||
|
||||
ip = "http://band.hxzhxy.cn"
|
||||
param = {
|
||||
"username": "xtl",
|
||||
"password": "xia123456",
|
||||
"client_id": "client",
|
||||
"grant_type": "password",
|
||||
"client_secret": "123456",
|
||||
}
|
||||
|
||||
def get_token():
|
||||
data = get(url=f"{ip}/oauth/token", params=param).json()
|
||||
return data["access_token"]
|
||||
|
||||
token = get_token()
|
||||
header = {
|
||||
"content-type": "application/json",
|
||||
"authorization": f"Bearer {token}",
|
||||
}
|
||||
teamId = 106
|
||||
|
||||
def generate_leave_data(stu_id, stu_name, stu_no, grade_name, class_name, grade_id, class_id, phone=None):
|
||||
leave_types = ["事假", "病假"]
|
||||
|
||||
leave_type = random.choice(leave_types)
|
||||
is_cycle = random.choice([1, 2, 3])
|
||||
|
||||
begin_date = datetime.now() - timedelta(days=random.randint(0,15))
|
||||
end_date = begin_date + timedelta(days=random.randint(0, 120))
|
||||
|
||||
begin_section = random.randint(1, 6)
|
||||
end_section = random.randint(begin_section, 12)
|
||||
|
||||
leave_reasons = [
|
||||
"身体不适,需要休息",
|
||||
"家中有事需要处理",
|
||||
"去医院检查身体",
|
||||
"发烧感冒,需要就医",
|
||||
"参加重要家庭活动",
|
||||
"个人事务需要处理",
|
||||
"肠胃不适,需要就医",
|
||||
"头痛发热,请假休息",
|
||||
"参加校外培训活动",
|
||||
"家庭紧急事务",
|
||||
]
|
||||
|
||||
disease_date = begin_date.strftime("%Y-%m-%d")
|
||||
|
||||
if is_cycle == 3:
|
||||
week_days = ["周一", "周二", "周三", "周四", "周五"]
|
||||
selected_day = random.choice(week_days)
|
||||
sections = random.sample(range(1, 13), random.randint(2, 4))
|
||||
sections.sort()
|
||||
week_info = json.dumps({selected_day: ",".join(str(s) for s in sections)})
|
||||
end_date = begin_date
|
||||
else:
|
||||
week_info = None
|
||||
|
||||
data = {
|
||||
"stuId": str(stu_id),
|
||||
"leaveType": leave_type,
|
||||
"isCycle": is_cycle,
|
||||
"leaveReason": random.choice(leave_reasons),
|
||||
"beginDate": begin_date.strftime("%Y-%m-%d"),
|
||||
"endDate": end_date.strftime("%Y-%m-%d"),
|
||||
"beginSection": str(begin_section),
|
||||
"endSection": str(end_section),
|
||||
"diseaseDate": disease_date,
|
||||
"symptom": "",
|
||||
"fever": "",
|
||||
"hospital": "",
|
||||
"treatmentDate": "",
|
||||
"imgUrl": "[]",
|
||||
"weekInfo": week_info,
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
def get_grade_list():
|
||||
url = f"{ip}/uc/grade/listSelect/{teamId}?access_token={token}"
|
||||
response = get(url, headers=header)
|
||||
result = response.json()
|
||||
if result.get('code') == 0:
|
||||
return result.get('data', [])
|
||||
return []
|
||||
|
||||
def get_class_list(grade_id):
|
||||
url = f"{ip}/uc/class/listClass"
|
||||
params = {
|
||||
"access_token": token,
|
||||
"teamId": teamId,
|
||||
"gradeId": grade_id
|
||||
}
|
||||
response = get(url, params=params, headers=header)
|
||||
result = response.json()
|
||||
if result.get('code') == 0:
|
||||
return result.get('data', [])
|
||||
return []
|
||||
|
||||
def get_students_from_db(grade_id=None, class_id=None):
|
||||
import pymysql
|
||||
conn = pymysql.connect(
|
||||
host='192.168.0.244',
|
||||
port=3306,
|
||||
user='root',
|
||||
password='Abcd@123456',
|
||||
database='school_server',
|
||||
charset='utf8'
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
sql = """
|
||||
SELECT s.id, s.stu_no, s.stu_name, s.phone,
|
||||
g.grade_name, c.class_name
|
||||
FROM student s
|
||||
LEFT JOIN grade g ON s.grade_id = g.id
|
||||
LEFT JOIN tclass c ON s.class_id = c.id
|
||||
WHERE s.team_id = %s
|
||||
"""
|
||||
params = [str(teamId)]
|
||||
|
||||
if grade_id:
|
||||
sql += " AND s.grade_id = %s"
|
||||
params.append(grade_id)
|
||||
if class_id:
|
||||
sql += " AND s.class_id = %s"
|
||||
params.append(class_id)
|
||||
|
||||
sql += " ORDER BY RAND() LIMIT 100"
|
||||
|
||||
cursor.execute(sql, params)
|
||||
students = cursor.fetchall()
|
||||
conn.close()
|
||||
return students
|
||||
|
||||
def add_leave_record(leave_data):
|
||||
url = f"{ip}/studentLeave/add"
|
||||
leave_data["access_token"] = token
|
||||
response = post(url, json=leave_data, headers=header)
|
||||
return response.json()
|
||||
|
||||
def batch_add_leaves(count=10):
|
||||
print(f"正在获取年级列表...")
|
||||
grades = get_grade_list()
|
||||
if not grades:
|
||||
print("未获取到年级数据,请检查 teamId 或 token")
|
||||
return
|
||||
|
||||
grade = random.choice(grades)
|
||||
grade_id = grade.get('id', grade.get('gradeId'))
|
||||
grade_name = grade.get('gradeName', grade.get('name', ''))
|
||||
print(f"随机选择年级: {grade_name}")
|
||||
|
||||
print(f"正在获取 [{grade_name}] 的班级列表...")
|
||||
classes = get_class_list(grade_id)
|
||||
if not classes:
|
||||
print("未获取到班级数据")
|
||||
return
|
||||
|
||||
cls = random.choice(classes)
|
||||
class_id = cls.get('id', cls.get('classId'))
|
||||
class_name = cls.get('className', cls.get('name', ''))
|
||||
print(f"随机选择班级: {class_name}")
|
||||
|
||||
print(f"\n正在从数据库获取 [{grade_name} {class_name}] 的学生数据...")
|
||||
students = get_students_from_db(grade_id, class_id)
|
||||
print(f"获取到 {len(students)} 名学生")
|
||||
|
||||
if not students:
|
||||
print("未获取到学生数据,请检查数据库连接")
|
||||
return
|
||||
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
|
||||
for i in range(min(count, len(students))):
|
||||
stu = students[i]
|
||||
stu_id, stu_no, stu_name, phone, db_grade_name, db_class_name = stu
|
||||
|
||||
leave_data = generate_leave_data(
|
||||
stu_id, stu_name, stu_no,
|
||||
grade_name, class_name, grade_id, class_id, phone
|
||||
)
|
||||
|
||||
print(f"\n[{i+1}/{min(count, len(students))}] 为学生 {stu_name}({stu_no}) 添加请假记录...")
|
||||
print(f" 请假类型: {leave_data['leaveType']}")
|
||||
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
|
||||
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}节")
|
||||
print(f" 请假事由: {leave_data['leaveReason']}")
|
||||
|
||||
try:
|
||||
result = add_leave_record(leave_data)
|
||||
if result.get('code') == 0:
|
||||
print(f" ✓ 添加成功")
|
||||
success_count += 1
|
||||
else:
|
||||
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
|
||||
fail_count += 1
|
||||
except Exception as e:
|
||||
print(f" ✗ 请求异常: {e}")
|
||||
fail_count += 1
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
print(f"\n{'='*50}")
|
||||
print(f"批量添加完成!")
|
||||
print(f"成功: {success_count} 条")
|
||||
print(f"失败: {fail_count} 条")
|
||||
|
||||
def generate_fake_students(count=20):
|
||||
students = []
|
||||
for i in range(count):
|
||||
stu = {
|
||||
"id": i + 1,
|
||||
"stu_no": f"2024{str(i+1).zfill(4)}",
|
||||
"stu_name": fake.name(),
|
||||
"phone": fake.phone_number(),
|
||||
"grade_name": random.choice(["初一", "初二", "初三", "高一", "高二", "高三"]),
|
||||
"class_name": f"{random.randint(1, 10)}班",
|
||||
}
|
||||
students.append(stu)
|
||||
return students
|
||||
|
||||
def batch_add_leaves_with_fake_students(count=10):
|
||||
print(f"使用 Faker 生成 {count} 条请假记录...")
|
||||
|
||||
students = generate_fake_students(count)
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
|
||||
for i, stu in enumerate(students):
|
||||
leave_data = generate_leave_data(
|
||||
stu['id'], stu['stu_name'], stu['stu_no'],
|
||||
stu['grade_name'], stu['class_name'],
|
||||
None, None, stu['phone']
|
||||
)
|
||||
|
||||
print(f"\n[{i+1}/{count}] 为学生 {stu['stu_name']}({stu['stu_no']}) 添加请假记录...")
|
||||
print(f" 请假类型: {leave_data['leaveType']}")
|
||||
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
|
||||
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}节")
|
||||
print(f" 请假事由: {leave_data['leaveReason']}")
|
||||
|
||||
try:
|
||||
result = add_leave_record(leave_data)
|
||||
if result.get('code') == 0:
|
||||
print(f" ✓ 添加成功")
|
||||
success_count += 1
|
||||
else:
|
||||
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
|
||||
fail_count += 1
|
||||
except Exception as e:
|
||||
print(f" ✗ 请求异常: {e}")
|
||||
fail_count += 1
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
print(f"\n{'='*50}")
|
||||
print(f"批量添加完成!")
|
||||
print(f"成功: {success_count} 条")
|
||||
print(f"失败: {fail_count} 条")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("="*50)
|
||||
print("批量添加学生请假信息")
|
||||
print("="*50)
|
||||
print("1. 从数据库获取学生并添加请假记录")
|
||||
print("2. 使用 Faker 生成虚拟学生并添加请假记录")
|
||||
print("="*50)
|
||||
|
||||
choice = input("请选择模式 (1/2): ").strip()
|
||||
count = int(input("请输入要生成的请假记录数量: ").strip() or "10")
|
||||
|
||||
if choice == "1":
|
||||
batch_add_leaves(count)
|
||||
elif choice == "2":
|
||||
batch_add_leaves_with_fake_students(count)
|
||||
else:
|
||||
print("无效选择")
|
||||
@@ -0,0 +1,288 @@
|
||||
from requests import get, post
|
||||
from faker import Faker
|
||||
import random
|
||||
import time
|
||||
import uuid
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
fake = Faker('zh_CN')
|
||||
|
||||
ip = "http://band.hxzhxy.cn"
|
||||
param = {
|
||||
"username": "xtl",
|
||||
"password": "xia123456",
|
||||
"client_id": "client",
|
||||
"grant_type": "password",
|
||||
"client_secret": "123456",
|
||||
}
|
||||
|
||||
def get_token():
|
||||
data = get(url=f"{ip}/oauth/token", params=param).json()
|
||||
return data["access_token"]
|
||||
|
||||
token = get_token()
|
||||
header = {
|
||||
"content-type": "application/json",
|
||||
"authorization": f"Bearer {token}",
|
||||
}
|
||||
teamId = 106
|
||||
|
||||
def generate_leave_data(stu_id, stu_name, stu_no, grade_name, class_name, grade_id, class_id, phone=None):
|
||||
leave_types = ["事假", "病假"]
|
||||
|
||||
leave_type = random.choice(leave_types)
|
||||
is_cycle = random.choice([1, 2, 3])
|
||||
|
||||
begin_date = datetime.now() - timedelta(days=random.randint(0,15))
|
||||
end_date = begin_date + timedelta(days=random.randint(0, 120))
|
||||
|
||||
begin_section = random.randint(1, 6)
|
||||
end_section = random.randint(begin_section, 12)
|
||||
|
||||
leave_reasons = [
|
||||
"身体不适,需要休息",
|
||||
"家中有事需要处理",
|
||||
"去医院检查身体",
|
||||
"发烧感冒,需要就医",
|
||||
"参加重要家庭活动",
|
||||
"个人事务需要处理",
|
||||
"肠胃不适,需要就医",
|
||||
"头痛发热,请假休息",
|
||||
"参加校外培训活动",
|
||||
"家庭紧急事务",
|
||||
]
|
||||
|
||||
disease_date = begin_date.strftime("%Y-%m-%d")
|
||||
|
||||
if is_cycle == 3:
|
||||
week_days = ["周一", "周二", "周三", "周四", "周五"]
|
||||
selected_day = random.choice(week_days)
|
||||
sections = random.sample(range(1, 13), random.randint(2, 4))
|
||||
sections.sort()
|
||||
week_info = json.dumps({selected_day: ",".join(str(s) for s in sections)})
|
||||
end_date = begin_date
|
||||
else:
|
||||
week_info = None
|
||||
|
||||
data = {
|
||||
"stuId": str(stu_id),
|
||||
"leaveType": leave_type,
|
||||
"isCycle": is_cycle,
|
||||
"leaveReason": random.choice(leave_reasons),
|
||||
"beginDate": begin_date.strftime("%Y-%m-%d"),
|
||||
"endDate": end_date.strftime("%Y-%m-%d"),
|
||||
"beginSection": str(begin_section),
|
||||
"endSection": str(end_section),
|
||||
"diseaseDate": disease_date,
|
||||
"symptom": "",
|
||||
"fever": "",
|
||||
"hospital": "",
|
||||
"treatmentDate": "",
|
||||
"imgUrl": "[]",
|
||||
"weekInfo": week_info,
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
def get_grade_list():
|
||||
url = f"{ip}/uc/grade/listSelect/{teamId}?access_token={token}"
|
||||
response = get(url, headers=header)
|
||||
result = response.json()
|
||||
if result.get('code') == 0:
|
||||
return result.get('data', [])
|
||||
return []
|
||||
|
||||
def get_class_list(grade_id):
|
||||
url = f"{ip}/uc/class/listClass"
|
||||
params = {
|
||||
"access_token": token,
|
||||
"teamId": teamId,
|
||||
"gradeId": grade_id
|
||||
}
|
||||
response = get(url, params=params, headers=header)
|
||||
result = response.json()
|
||||
if result.get('code') == 0:
|
||||
return result.get('data', [])
|
||||
return []
|
||||
|
||||
def get_students_from_db(grade_id=None, class_id=None):
|
||||
import pymysql
|
||||
conn = pymysql.connect(
|
||||
host='100.64.0.36',
|
||||
port=3306,
|
||||
user='root',
|
||||
password='@HXYD1109mysql',
|
||||
database='school_server',
|
||||
charset='utf8'
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
sql = """
|
||||
SELECT s.id, s.stu_no, s.stu_name, s.phone,
|
||||
g.grade_name, c.class_name
|
||||
FROM student s
|
||||
LEFT JOIN grade g ON s.grade_id = g.id
|
||||
LEFT JOIN tclass c ON s.class_id = c.id
|
||||
WHERE s.team_id = %s
|
||||
"""
|
||||
params = [str(teamId)]
|
||||
|
||||
if grade_id:
|
||||
sql += " AND s.grade_id = %s"
|
||||
params.append(grade_id)
|
||||
if class_id:
|
||||
sql += " AND s.class_id = %s"
|
||||
params.append(class_id)
|
||||
|
||||
sql += " ORDER BY RAND() LIMIT 100"
|
||||
|
||||
cursor.execute(sql, params)
|
||||
students = cursor.fetchall()
|
||||
conn.close()
|
||||
return students
|
||||
|
||||
def add_leave_record(leave_data):
|
||||
url = f"{ip}/studentLeave/add"
|
||||
leave_data["access_token"] = token
|
||||
response = post(url, json=leave_data, headers=header)
|
||||
return response.json()
|
||||
|
||||
def batch_add_leaves(count=10):
|
||||
print(f"正在获取年级列表...")
|
||||
grades = get_grade_list()
|
||||
if not grades:
|
||||
print("未获取到年级数据,请检查 teamId 或 token")
|
||||
return
|
||||
|
||||
grade = random.choice(grades)
|
||||
grade_id = grade.get('id', grade.get('gradeId'))
|
||||
grade_name = grade.get('gradeName', grade.get('name', ''))
|
||||
print(f"随机选择年级: {grade_name}")
|
||||
|
||||
print(f"正在获取 [{grade_name}] 的班级列表...")
|
||||
classes = get_class_list(grade_id)
|
||||
if not classes:
|
||||
print("未获取到班级数据")
|
||||
return
|
||||
|
||||
cls = random.choice(classes)
|
||||
class_id = cls.get('id', cls.get('classId'))
|
||||
class_name = cls.get('className', cls.get('name', ''))
|
||||
print(f"随机选择班级: {class_name}")
|
||||
|
||||
print(f"\n正在从数据库获取 [{grade_name} {class_name}] 的学生数据...")
|
||||
students = get_students_from_db(grade_id, class_id)
|
||||
print(f"获取到 {len(students)} 名学生")
|
||||
|
||||
if not students:
|
||||
print("未获取到学生数据,请检查数据库连接")
|
||||
return
|
||||
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
|
||||
for i in range(min(count, len(students))):
|
||||
stu = students[i]
|
||||
stu_id, stu_no, stu_name, phone, db_grade_name, db_class_name = stu
|
||||
|
||||
leave_data = generate_leave_data(
|
||||
stu_id, stu_name, stu_no,
|
||||
grade_name, class_name, grade_id, class_id, phone
|
||||
)
|
||||
|
||||
print(f"\n[{i+1}/{min(count, len(students))}] 为学生 {stu_name}({stu_no}) 添加请假记录...")
|
||||
print(f" 请假类型: {leave_data['leaveType']}")
|
||||
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
|
||||
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}节")
|
||||
print(f" 请假事由: {leave_data['leaveReason']}")
|
||||
|
||||
try:
|
||||
result = add_leave_record(leave_data)
|
||||
if result.get('code') == 0:
|
||||
print(f" ✓ 添加成功")
|
||||
success_count += 1
|
||||
else:
|
||||
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
|
||||
fail_count += 1
|
||||
except Exception as e:
|
||||
print(f" ✗ 请求异常: {e}")
|
||||
fail_count += 1
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
print(f"\n{'='*50}")
|
||||
print(f"批量添加完成!")
|
||||
print(f"成功: {success_count} 条")
|
||||
print(f"失败: {fail_count} 条")
|
||||
|
||||
def generate_fake_students(count=20):
|
||||
students = []
|
||||
for i in range(count):
|
||||
stu = {
|
||||
"id": i + 1,
|
||||
"stu_no": f"2024{str(i+1).zfill(4)}",
|
||||
"stu_name": fake.name(),
|
||||
"phone": fake.phone_number(),
|
||||
"grade_name": random.choice(["初一", "初二", "初三", "高一", "高二", "高三"]),
|
||||
"class_name": f"{random.randint(1, 10)}班",
|
||||
}
|
||||
students.append(stu)
|
||||
return students
|
||||
|
||||
def batch_add_leaves_with_fake_students(count=10):
|
||||
print(f"使用 Faker 生成 {count} 条请假记录...")
|
||||
|
||||
students = generate_fake_students(count)
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
|
||||
for i, stu in enumerate(students):
|
||||
leave_data = generate_leave_data(
|
||||
stu['id'], stu['stu_name'], stu['stu_no'],
|
||||
stu['grade_name'], stu['class_name'],
|
||||
None, None, stu['phone']
|
||||
)
|
||||
|
||||
print(f"\n[{i+1}/{count}] 为学生 {stu['stu_name']}({stu['stu_no']}) 添加请假记录...")
|
||||
print(f" 请假类型: {leave_data['leaveType']}")
|
||||
print(f" 请假时间: {leave_data['beginDate']} ~ {leave_data['endDate']}")
|
||||
print(f" 请假节次: 第{leave_data['beginSection']}节 ~ 第{leave_data['endSection']}节")
|
||||
print(f" 请假事由: {leave_data['leaveReason']}")
|
||||
|
||||
try:
|
||||
result = add_leave_record(leave_data)
|
||||
if result.get('code') == 0:
|
||||
print(f" ✓ 添加成功")
|
||||
success_count += 1
|
||||
else:
|
||||
print(f" ✗ 添加失败: {result.get('msg', '未知错误')}")
|
||||
fail_count += 1
|
||||
except Exception as e:
|
||||
print(f" ✗ 请求异常: {e}")
|
||||
fail_count += 1
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
print(f"\n{'='*50}")
|
||||
print(f"批量添加完成!")
|
||||
print(f"成功: {success_count} 条")
|
||||
print(f"失败: {fail_count} 条")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("="*50)
|
||||
print("批量添加学生请假信息")
|
||||
print("="*50)
|
||||
print("1. 从数据库获取学生并添加请假记录")
|
||||
print("2. 使用 Faker 生成虚拟学生并添加请假记录")
|
||||
print("="*50)
|
||||
|
||||
choice = input("请选择模式 (1/2): ").strip()
|
||||
count = int(input("请输入要生成的请假记录数量: ").strip() or "10")
|
||||
|
||||
if choice == "1":
|
||||
batch_add_leaves(count)
|
||||
elif choice == "2":
|
||||
batch_add_leaves_with_fake_students(count)
|
||||
else:
|
||||
print("无效选择")
|
||||
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "318e7588",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "",
|
||||
"evalue": "",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。\n",
|
||||
"\u001b[1;31m请查看单元格中的代码,以确定故障的可能原因。\n",
|
||||
"\u001b[1;31m单击<a href='https://aka.ms/vscodeJupyterKernelCrash'>此处</a>了解详细信息。\n",
|
||||
"\u001b[1;31m有关更多详细信息,请查看 Jupyter <a href='command:jupyter.viewOutput'>log</a>。"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from requests import get,post\n",
|
||||
"import time\n",
|
||||
"ip = \"http://192.168.0.244:8100\"\n",
|
||||
"param = {\n",
|
||||
" \"username\": \"jz97621\",\n",
|
||||
" \"password\": \"123456a\",\n",
|
||||
" \"client_id\": \"client\",\n",
|
||||
" \"grant_type\": \"password\",\n",
|
||||
" \"client_secret\": \"123456\",\n",
|
||||
"}\n",
|
||||
"data = get(url=f\"{ip}/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": null,
|
||||
"id": "3c046d8d",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ReadTimeout",
|
||||
"evalue": "HTTPConnectionPool(host='192.168.0.209', port=8100): Read timed out. (read timeout=600)",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mTimeoutError\u001b[0m Traceback (most recent call last)",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:534\u001b[0m, in \u001b[0;36mHTTPConnectionPool._make_request\u001b[1;34m(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)\u001b[0m\n\u001b[0;32m 533\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 534\u001b[0m response \u001b[38;5;241m=\u001b[39m conn\u001b[38;5;241m.\u001b[39mgetresponse()\n\u001b[0;32m 535\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (BaseSSLError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connection.py:565\u001b[0m, in \u001b[0;36mHTTPConnection.getresponse\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 564\u001b[0m \u001b[38;5;66;03m# Get the response from http.client.HTTPConnection\u001b[39;00m\n\u001b[1;32m--> 565\u001b[0m httplib_response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39mgetresponse()\n\u001b[0;32m 567\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\http\\client.py:1428\u001b[0m, in \u001b[0;36mHTTPConnection.getresponse\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1427\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1428\u001b[0m response\u001b[38;5;241m.\u001b[39mbegin()\n\u001b[0;32m 1429\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mConnectionError\u001b[39;00m:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\http\\client.py:331\u001b[0m, in \u001b[0;36mHTTPResponse.begin\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 330\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[1;32m--> 331\u001b[0m version, status, reason \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_read_status()\n\u001b[0;32m 332\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m status \u001b[38;5;241m!=\u001b[39m CONTINUE:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\http\\client.py:292\u001b[0m, in \u001b[0;36mHTTPResponse._read_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 291\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_read_status\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m--> 292\u001b[0m line \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfp\u001b[38;5;241m.\u001b[39mreadline(_MAXLINE \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m), \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124miso-8859-1\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 293\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(line) \u001b[38;5;241m>\u001b[39m _MAXLINE:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\socket.py:708\u001b[0m, in \u001b[0;36mSocketIO.readinto\u001b[1;34m(self, b)\u001b[0m\n\u001b[0;32m 707\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 708\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sock\u001b[38;5;241m.\u001b[39mrecv_into(b)\n\u001b[0;32m 709\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m timeout:\n",
|
||||
"\u001b[1;31mTimeoutError\u001b[0m: timed out",
|
||||
"\nThe above exception was the direct cause of the following exception:\n",
|
||||
"\u001b[1;31mReadTimeoutError\u001b[0m Traceback (most recent call last)",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\adapters.py:589\u001b[0m, in \u001b[0;36mHTTPAdapter.send\u001b[1;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[0;32m 588\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 589\u001b[0m resp \u001b[38;5;241m=\u001b[39m conn\u001b[38;5;241m.\u001b[39murlopen(\n\u001b[0;32m 590\u001b[0m method\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mmethod,\n\u001b[0;32m 591\u001b[0m url\u001b[38;5;241m=\u001b[39murl,\n\u001b[0;32m 592\u001b[0m body\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mbody,\n\u001b[0;32m 593\u001b[0m headers\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mheaders,\n\u001b[0;32m 594\u001b[0m redirect\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 595\u001b[0m assert_same_host\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 596\u001b[0m preload_content\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 597\u001b[0m decode_content\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 598\u001b[0m retries\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmax_retries,\n\u001b[0;32m 599\u001b[0m timeout\u001b[38;5;241m=\u001b[39mtimeout,\n\u001b[0;32m 600\u001b[0m chunked\u001b[38;5;241m=\u001b[39mchunked,\n\u001b[0;32m 601\u001b[0m )\n\u001b[0;32m 603\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (ProtocolError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m err:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:841\u001b[0m, in \u001b[0;36mHTTPConnectionPool.urlopen\u001b[1;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)\u001b[0m\n\u001b[0;32m 839\u001b[0m new_e \u001b[38;5;241m=\u001b[39m ProtocolError(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConnection aborted.\u001b[39m\u001b[38;5;124m\"\u001b[39m, new_e)\n\u001b[1;32m--> 841\u001b[0m retries \u001b[38;5;241m=\u001b[39m retries\u001b[38;5;241m.\u001b[39mincrement(\n\u001b[0;32m 842\u001b[0m method, url, error\u001b[38;5;241m=\u001b[39mnew_e, _pool\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m, _stacktrace\u001b[38;5;241m=\u001b[39msys\u001b[38;5;241m.\u001b[39mexc_info()[\u001b[38;5;241m2\u001b[39m]\n\u001b[0;32m 843\u001b[0m )\n\u001b[0;32m 844\u001b[0m retries\u001b[38;5;241m.\u001b[39msleep()\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\util\\retry.py:474\u001b[0m, in \u001b[0;36mRetry.increment\u001b[1;34m(self, method, url, response, error, _pool, _stacktrace)\u001b[0m\n\u001b[0;32m 473\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m read \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m \u001b[38;5;129;01mor\u001b[39;00m method \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_is_method_retryable(method):\n\u001b[1;32m--> 474\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m reraise(\u001b[38;5;28mtype\u001b[39m(error), error, _stacktrace)\n\u001b[0;32m 475\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m read \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\util\\util.py:39\u001b[0m, in \u001b[0;36mreraise\u001b[1;34m(tp, value, tb)\u001b[0m\n\u001b[0;32m 38\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m value\u001b[38;5;241m.\u001b[39mwith_traceback(tb)\n\u001b[1;32m---> 39\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m value\n\u001b[0;32m 40\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:787\u001b[0m, in \u001b[0;36mHTTPConnectionPool.urlopen\u001b[1;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)\u001b[0m\n\u001b[0;32m 786\u001b[0m \u001b[38;5;66;03m# Make the request on the HTTPConnection object\u001b[39;00m\n\u001b[1;32m--> 787\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_make_request(\n\u001b[0;32m 788\u001b[0m conn,\n\u001b[0;32m 789\u001b[0m method,\n\u001b[0;32m 790\u001b[0m url,\n\u001b[0;32m 791\u001b[0m timeout\u001b[38;5;241m=\u001b[39mtimeout_obj,\n\u001b[0;32m 792\u001b[0m body\u001b[38;5;241m=\u001b[39mbody,\n\u001b[0;32m 793\u001b[0m headers\u001b[38;5;241m=\u001b[39mheaders,\n\u001b[0;32m 794\u001b[0m chunked\u001b[38;5;241m=\u001b[39mchunked,\n\u001b[0;32m 795\u001b[0m retries\u001b[38;5;241m=\u001b[39mretries,\n\u001b[0;32m 796\u001b[0m response_conn\u001b[38;5;241m=\u001b[39mresponse_conn,\n\u001b[0;32m 797\u001b[0m preload_content\u001b[38;5;241m=\u001b[39mpreload_content,\n\u001b[0;32m 798\u001b[0m decode_content\u001b[38;5;241m=\u001b[39mdecode_content,\n\u001b[0;32m 799\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mresponse_kw,\n\u001b[0;32m 800\u001b[0m )\n\u001b[0;32m 802\u001b[0m \u001b[38;5;66;03m# Everything went great!\u001b[39;00m\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:536\u001b[0m, in \u001b[0;36mHTTPConnectionPool._make_request\u001b[1;34m(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)\u001b[0m\n\u001b[0;32m 535\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (BaseSSLError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m--> 536\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_raise_timeout(err\u001b[38;5;241m=\u001b[39me, url\u001b[38;5;241m=\u001b[39murl, timeout_value\u001b[38;5;241m=\u001b[39mread_timeout)\n\u001b[0;32m 537\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:367\u001b[0m, in \u001b[0;36mHTTPConnectionPool._raise_timeout\u001b[1;34m(self, err, url, timeout_value)\u001b[0m\n\u001b[0;32m 366\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(err, SocketTimeout):\n\u001b[1;32m--> 367\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ReadTimeoutError(\n\u001b[0;32m 368\u001b[0m \u001b[38;5;28mself\u001b[39m, url, \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRead timed out. (read timeout=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mtimeout_value\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 369\u001b[0m ) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[0;32m 371\u001b[0m \u001b[38;5;66;03m# See the above comment about EAGAIN in Python 3.\u001b[39;00m\n",
|
||||
"\u001b[1;31mReadTimeoutError\u001b[0m: HTTPConnectionPool(host='192.168.0.209', port=8100): Read timed out. (read timeout=600)",
|
||||
"\nDuring handling of the above exception, another exception occurred:\n",
|
||||
"\u001b[1;31mReadTimeout\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[1;32mIn[2], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m35\u001b[39m,\u001b[38;5;241m36\u001b[39m):\n\u001b[1;32m----> 2\u001b[0m post(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mip\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/classAttendStu/createThisWeek\u001b[39m\u001b[38;5;124m\"\u001b[39m,headers\u001b[38;5;241m=\u001b[39mheader,params\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mplanId\u001b[39m\u001b[38;5;124m\"\u001b[39m:i},timeout\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m600\u001b[39m)\u001b[38;5;241m.\u001b[39mtext\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\api.py:115\u001b[0m, in \u001b[0;36mpost\u001b[1;34m(url, data, json, **kwargs)\u001b[0m\n\u001b[0;32m 103\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mpost\u001b[39m(url, data\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, json\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m 104\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124;03m\"\"\"Sends a POST request.\u001b[39;00m\n\u001b[0;32m 105\u001b[0m \n\u001b[0;32m 106\u001b[0m \u001b[38;5;124;03m :param url: URL for the new :class:`Request` object.\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 112\u001b[0m \u001b[38;5;124;03m :rtype: requests.Response\u001b[39;00m\n\u001b[0;32m 113\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 115\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m request(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpost\u001b[39m\u001b[38;5;124m\"\u001b[39m, url, data\u001b[38;5;241m=\u001b[39mdata, json\u001b[38;5;241m=\u001b[39mjson, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\api.py:59\u001b[0m, in \u001b[0;36mrequest\u001b[1;34m(method, url, **kwargs)\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;66;03m# By using the 'with' statement we are sure the session is closed, thus we\u001b[39;00m\n\u001b[0;32m 56\u001b[0m \u001b[38;5;66;03m# avoid leaving sockets open which can trigger a ResourceWarning in some\u001b[39;00m\n\u001b[0;32m 57\u001b[0m \u001b[38;5;66;03m# cases, and look like a memory leak in others.\u001b[39;00m\n\u001b[0;32m 58\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m sessions\u001b[38;5;241m.\u001b[39mSession() \u001b[38;5;28;01mas\u001b[39;00m session:\n\u001b[1;32m---> 59\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m session\u001b[38;5;241m.\u001b[39mrequest(method\u001b[38;5;241m=\u001b[39mmethod, url\u001b[38;5;241m=\u001b[39murl, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\sessions.py:589\u001b[0m, in \u001b[0;36mSession.request\u001b[1;34m(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)\u001b[0m\n\u001b[0;32m 584\u001b[0m send_kwargs \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m 585\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimeout\u001b[39m\u001b[38;5;124m\"\u001b[39m: timeout,\n\u001b[0;32m 586\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mallow_redirects\u001b[39m\u001b[38;5;124m\"\u001b[39m: allow_redirects,\n\u001b[0;32m 587\u001b[0m }\n\u001b[0;32m 588\u001b[0m send_kwargs\u001b[38;5;241m.\u001b[39mupdate(settings)\n\u001b[1;32m--> 589\u001b[0m resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msend(prep, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39msend_kwargs)\n\u001b[0;32m 591\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m resp\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\sessions.py:703\u001b[0m, in \u001b[0;36mSession.send\u001b[1;34m(self, request, **kwargs)\u001b[0m\n\u001b[0;32m 700\u001b[0m start \u001b[38;5;241m=\u001b[39m preferred_clock()\n\u001b[0;32m 702\u001b[0m \u001b[38;5;66;03m# Send the request\u001b[39;00m\n\u001b[1;32m--> 703\u001b[0m r \u001b[38;5;241m=\u001b[39m adapter\u001b[38;5;241m.\u001b[39msend(request, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 705\u001b[0m \u001b[38;5;66;03m# Total elapsed time of the request (approximately)\u001b[39;00m\n\u001b[0;32m 706\u001b[0m elapsed \u001b[38;5;241m=\u001b[39m preferred_clock() \u001b[38;5;241m-\u001b[39m start\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\requests\\adapters.py:635\u001b[0m, in \u001b[0;36mHTTPAdapter.send\u001b[1;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[0;32m 633\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m SSLError(e, request\u001b[38;5;241m=\u001b[39mrequest)\n\u001b[0;32m 634\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(e, ReadTimeoutError):\n\u001b[1;32m--> 635\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ReadTimeout(e, request\u001b[38;5;241m=\u001b[39mrequest)\n\u001b[0;32m 636\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(e, _InvalidHeader):\n\u001b[0;32m 637\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidHeader(e, request\u001b[38;5;241m=\u001b[39mrequest)\n",
|
||||
"\u001b[1;31mReadTimeout\u001b[0m: HTTPConnectionPool(host='192.168.0.209', port=8100): Read timed out. (read timeout=600)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "",
|
||||
"evalue": "",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。\n",
|
||||
"\u001b[1;31m请查看单元格中的代码,以确定故障的可能原因。\n",
|
||||
"\u001b[1;31m单击<a href='https://aka.ms/vscodeJupyterKernelCrash'>此处</a>了解详细信息。\n",
|
||||
"\u001b[1;31m有关更多详细信息,请查看 Jupyter <a href='command:jupyter.viewOutput'>log</a>。"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for i in range(35,36):\n",
|
||||
" post(f\"{ip}/classAttendStu/createThisWeek\",headers=header,params={\"planId\":i},timeout=600).text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "343a9e44",
|
||||
"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
|
||||
}
|
||||
Reference in New Issue
Block a user