GithubHelp home page GithubHelp logo

whu-coursegrade's Introduction

由于因不可抗力,梦想珈“查给分”功能已下线,本项目暂无可用数据源,现停止维护

截至2021年9月以前的数据将汇总上传

武汉大学课程历史给分批量获取脚本

所有数据均来自于网上,本项目对数据真实性不做保证

如有侵权,请联系我删除

禁止用于非法用途,违者后果自负

环境要求

  • python3.7及以上
  • MySQL数据库(可选)

使用方法

1. 下载项目

git clone https://github.com/NagisaCo/CourseGrade.git
cd CourseGrade
pip install -r requirements.txt

如果执行pip install时提示-bash: pip: command not found 就是pip命令没有安装,执行下方命令安装即可,然后再执行即可

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

2. 填写配置文件

若目录下不存在config.ini配置文件,请先执行python CourseGrade.py或双击CourseGrade.py后获取配置文件模板

WL3BIU.png

根据个人实际填写配置文件,详细填写方法请见配置文件填写

WL86k8.png

3. 执行程序

运行CourseGrade.py得到运行结果,结果保存至result文件中,可使用__loadFile()函数加载。若配置数据库属性,则可以从数据库中查看结果

WLGx2Q.png

配置文件填写

#config.ini
[base]
htmlsource = 

[bkxk]
gnmkdm = N253512
studentnum = 
encryptedpassword = 

[mxj]
token = 

[db]
server = 
username = 
encryptedpassword = 
database = 

#[bkxk]和[db]中的encryptedPassword项为经过Encryptor.py加密后的密码
#[db]不填写自动关闭数据库存储任务
参数 注释
base.htmlsource 课程id获取来源 本地html路径或者url
bkxk.gnmkdm 暂不清楚该项的作用 默认值为N253512
bkxk.studentnum 学号,登录选课网页的用户名 13位数字
bkxk.encryptedpassword 加密后的登录选课网页密码 Base64
mxj.token 小程序梦想珈登录token 32位token
db.server 数据库服务器地址 域名或ip地址
db.username 数据库登录用户名 字符串
db.encryptedpassword 加密后的数据库登录密码 Base64
db.database 数据库名称 字符串

base

  • htmlsource

    htmlsource为课程id获取来源

    在选课界面,使用F12调出浏览器(以Chrome为例)的Console(控制台)界面,执行以下代码加载全部可选课程

    while(document.getElementById("isEnd").value!=="true") {loadCoursesByPaged();}

    WLNTW8.png

    将静态页面另存为html保存至本地,或者http服务器上

    在网页空白处 右键 选择 另存为 选择 保存类型:网页,全部

    htmlsource中填写文件路径或url地址

[base]
htmlsource = ./自主选课.html

bkxk

  • gnmkdm

    暂不清楚该项的作用,猜测为区分课程表,默认值为N253512,请在选课页面的url中获取相应值

    WLdRL4.png

  • studentnum

    学号,即登录选课网页的用户名

  • encryptedpassword

    登录选课网页的密码

    为避免明文保存密码,请使用Encryptor.py加密登录密码后填写加密后的密码

    执行python Encryptor.py或双击Encryptor.py,在窗口中输入登录密码,回车提交后获取加密后密码。加密密码同时也存储在剪贴板中,可使用Ctrl+V直接粘贴至encryptedpassword

    WLwDne.png

[bkxk]
gnmkdm = N25xxxx
studentnum = 20xxxxxxxxxxx
encryptedpassword = CB3mBPjM5h4ly3IHcu3aGj+2vYE/FX6N/QNgr4FkBwdw+mDVmCboXCbGm3j//dNVWx8A5wknKsLrx/ZoHpGbGLmlQNd6EZ/Ip5lHRXcbfwH94LRApu8GaIk/X+ngUG3b1tK7cwiE05r0sTIMoJ16ysIXb6V/rnVj7pwZVHvw414=

mxj

[mxj]
token = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

db

当db项目为空时,自动关闭更新数据库操作

数据库格式可通过course_grade.sql导入

  1. 登录数据库
mysql -u root -p
  1. 新建数据库并导入sql文件
CREATE DATABASE course_grade;
USE course_grade;
SOURCE ./course_grade.sql;

或者使用Navicat等GUI界面操作

WLLAu8.png]

  • server

    数据库服务器地址

  • username

    数据库登录用户名

  • encryptedpassword

    数据库登录密码,经过Encryptor.py加密

  • database

    数据库名称

[db]
server = localhost
username = course_grade
encryptedpassword = pZE7DFk4Ral78riF7bwt3u5wk8Xf34RZw0/ZEx3OtdxoXXK6rXm+xaCut3Dvr54W6u+KrmhjwlrID19WBLd4+AIDEQKZo4LofRWCPdUJdAV8qmkFpV7OoqXJY6KykYHu5saH9Saq5cLVCyHQe0pVieYYePkALjB75jvoPZDtiR4=
database = course_grade

结果

  • 本地Result保存

    查询结果由__storeFile()函数将CourseInfo类的List存储至本地,可由__loadFile()重新加载,无需再次进行爬虫操作。

  • 数据库保存

    当配置文件中db项目填写有效后,会自动更新数据库中的内容。

    WOVLvT.png

文件详情

CourseGrade
│  .gitattributes
│  .gitignore
│  course.html          选课网页副本(提取courseid)
│  CourseGrade.py       主程序(程序运行)
│  CourseGrade.pyproj   CourseGrade项目
│  CourseGrade.sln      VS解决方案(程序修改)
│  course_grade.sql     MySQL数据库创建模板(MySQL执行)
│  Encryptor.py         密码加密程序(程序运行)
│  LICENSE              GPL-3.0 License
│  package-lock.json
│  package.json         npm文件(commitizen 规范化commit提交)
│  README.md            本文件
│  requirements.txt     项目依赖(运行前安装)
│  result               结果结构化保存(用于本地保存CourseInfo类的列表)
│  result.xlsx          结果Excel导出(便于数据分析)
│
└─Tools                 工具包
    │  ConfigLoader.py  配置文件加载
    │  CourseId.py      获取CourseID
    │  CourseInfo.py    获取CourseInfo
    │  DB.py            数据库操作
    │  Exception.py     异常
    │  GradeInfo.py     获取GradeInfo
    │  Tool.py          工具
    │  __init__.py
    │
    └─API               API包
            bkxk.py     选课网页
            mxj.py      梦想珈小程序
            __init__.py

whu-coursegrade's People

Contributors

nagico avatar

Stargazers

zyy avatar  avatar GitHub's student certification is really stupid. avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.