Commit 2ea22d29 authored by Nairong Xie's avatar Nairong Xie
Browse files

Add checkin

# NJU Health Checkin Script
# Copyright (C) 2021 Maxwell Lyu
import os
import json
import random
import base64
import requests
from Crypto.Cipher import AES
from Crypto.Util import Padding
from bs4 import BeautifulSoup
def main():
def encryptAES(_p0: str, _p1: str) -> str:
_chars = list('ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678')
def _rds(len: int) -> str:
return ''.join(random.choices(_chars, k=len))
def _gas(data: str, key0: str, iv0: str) -> bytes:
encrypt ='utf-8'), AES.MODE_CBC, iv0.encode('utf-8'))
return base64.b64encode(encrypt.encrypt(Padding.pad(data.encode('utf-8'), 16)))
return _gas(_rds(64) + _p0, _p1, _rds(16)).decode('utf-8')
username = os.environ['NJU_USER']
password = os.environ['NJU_PASS']
url_login = r''
url_list = r''
url_apply = r''
session = requests.Session()
# login
response = session.get(url_login)
soup = BeautifulSoup(response.text, 'html.parser')
data_login = {
'username': username,
'password': encryptAES(password, soup.select_one("#pwdDefaultEncryptSalt").attrs['value']),
'lt': soup.select_one('[name="lt"]').attrs['value'],
'dllt': soup.select_one('[name="dllt"]').attrs['value'],
'execution': soup.select_one('[name="execution"]').attrs['value'],
'_eventId': soup.select_one('[name="_eventId"]').attrs['value'],
'rmShown': soup.select_one('[name="rmShown"]').attrs['value'],
}, data_login)
# list
content = session.get(url_list).json()
# apply
data = next(x for x in content['data'] if x.get('TJSJ') != '')
data['WID'] = content['data'][0]['WID']
fields = [
result = session.get('' +
'&'.join([key + '=' + data[key] for key in fields]))
if result.status_code != 200:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment