Open Anyexyz opened 1 year ago
root_url = "https://#####.xuetangx.com/"
get_university_data = json.loads((requests.request( # 获取"university_id"及"platform_id"
"GET", root_url + "edu_admin/get_custom_university_info/?current=1", headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 HBPC/12.1.2.300',
'Accept': '*/*',
'Connection': 'keep-alive'
})).text)["data"]
universityid = str(get_university_data["university_id"])
platformid = str(get_university_data["platform_id"])
# print(get_university_data["university_name"]) //学校名称
def get_weixin():
message = json.dumps(
{"op": "requestlogin", "role": "web", "type": "qrcode", "version": "1.4"})
uri = "wss://" + urlparse(root_url).netloc + "/wsapp/"
ws = websocket.create_connection(uri, timeout=30)
ws.send(message)
while True:
result = ws.recv()
url_weixin = json.loads(result)["ticket"]
print(url_weixin) # 二维码链接
user_info = ws.recv()
# put_text(user_info)
return user_info
get_weixin_info = get_weixin()
name = json.loads(get_weixin_info)["Name"] # 姓名
userid = json.loads(get_weixin_info)["UserID"] # userid
get_cs_se = requests.request("POST", root_url + "edu_admin/account/login/verify-origin-system-bind", headers={
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="99"',
'sec-ch-ua-mobile': '?0',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 HBPC/12.1.2.300',
'accept': 'application/json, text/plain, */*',
'platform-id': '3',
'xtbz': 'cloud',
'university-id': universityid,
'x-csrftoken': 'undefined',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-site': 'same-origin',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
'accept-language': 'zh-CN,zh;q=0.9',
'content-type': 'application/json',
'Connection': 'keep-alive'
}, data=json.dumps({
"origin_user_id": userid
}))
csrftoken = requests.utils.dict_from_cookiejar(get_cs_se.cookies)['csrftoken']
sessionid = requests.utils.dict_from_cookiejar(get_cs_se.cookies)['sessionid']
研究发现,我所在学校雨课堂校园特供版通过ws来传输微信登录二维码,则可模拟wss请求来获取微信二维码模拟登录,搭配pywebio可以实现扫描二维码推广使用