Skip to content

Instantly share code, notes, and snippets.

@Konano
Last active October 28, 2020 06:29
Show Gist options
  • Save Konano/b1576acfe61e0fdf2b3b60ab535ef6ae to your computer and use it in GitHub Desktop.
Save Konano/b1576acfe61e0fdf2b3b60ab535ef6ae to your computer and use it in GitHub Desktop.
report temp
import requests
import http.cookiejar as HC
import re, json, random
user = 2017011000 # need modify
pwd = 'password' # need modify
temp = '36.0'
session = requests.session()
session.cookies = HC.LWPCookieJar(filename='cookies')
try:
session.cookies.load(ignore_discard=True)
except:
pass
r = session.post('https://zijing.tsinghua.edu.cn/tp_jp/getToken')
if r.url != 'https://zijing.tsinghua.edu.cn/tp_jp/getToken':
r = session.post(f'https://id.tsinghua.edu.cn/do/off/ui/auth/login/check', data={'i_user': user, 'i_pass': pwd, 'i_captcha': ''})
r = session.post(re.findall(r'(?<=window.location.replace\(").*(?="\);)',r.text)[0])
r = session.post('https://zijing.tsinghua.edu.cn/tp_jp/getToken')
print('login successful')
data = {'tw':temp,'token':r.text}
headers = {'Content-Type':'application/json;charset=UTF-8'}
r = session.post('https://zijing.tsinghua.edu.cn/tp_jp/jp/temporary/confirmTw', headers=headers, data=json.dumps(data))
print(r.request.body)
if r.ok:
print(r.text)
else:
print(r.status_code)
session.cookies.save(ignore_discard=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment