-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_result.py
More file actions
48 lines (38 loc) · 1.7 KB
/
Copy pathshow_result.py
File metadata and controls
48 lines (38 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import requests
from bs4 import BeautifulSoup
from requestresult import SuccessPage, UnionAuth
def distinguish_and_build(page_soup: BeautifulSoup):
title = page_soup.find("title").text
if title == "系统提示" or title == "智慧东大--统一身份认证":
return UnionAuth(page_soup)
elif title == "IP控制网关":
return SuccessPage(page_soup)
else:
return None
def print_login_successful(page: SuccessPage):
if page.status == 0:
if page.online_other_uid:
print("other online, uid:", page.online_other_uid)
else:
print("account: {}\nip: {}\nconsumed: {}\nonline: {}\n".format(page.base_info[0], page.base_info[1],
page.base_info[2], page.base_info[3]))
for device in page.device_list:
print(device)
elif page.status == 1:
print("account locked, unlock first.")
elif page.status == 2:
print("insufficient funds.")
def print_fail_auth(page: UnionAuth):
if page.locked:
print("fail 5 times, account locked for 1 min.")
return
print("username or password error, last try {} times.".format(page.last_temp))
def read_settings_into_session(settings, session: requests.Session, set_cookie: bool,
set_headers: bool = True):
cookie_dict = settings["ipgw_cookie_jar"]
header_dict = settings["global_headers"]
if set_cookie:
requests.utils.cookiejar_from_dict(cookie_dict, session.cookies)
session.headers.update(header_dict)
def read_unpw_from_settings(settings: dict):
return settings["unity_login"]["username"], settings["unity_login"]["password"]