def __init__(self, url, name=None, code=None, use_ex_handle=True, exist_verify=True, lan_url=None, proxies=None, priority_proxy=False, timeout=10, login_url_path=None, url_path_list=None, class_time_list=None, session=None): school = { 'code': code, 'lan_url': lan_url, 'proxies': proxies, 'timeout': timeout, 'name': to_text(name), 'exist_verify': exist_verify, 'use_ex_handle': use_ex_handle, 'priority_proxy': priority_proxy, 'login_url': login_url_path or "/default2.aspx", 'url_path_list': url_path_list or URL_PATH_LIST, 'time_list': get_time_list(class_time_list or CLASS_TIME) } self.base_url = url.split('/default')[0] if url[-4:] == 'aspx' else url self.session = session or MemoryStorage() self.school = ObjectDict(school)
def __init__(self, url, name=None, code=None, use_ex_handle=True, exist_verify=True, lan_url=None, proxies=None, priority_proxy=False, timeout=10, login_url_path='/default2.aspx', url_endpoint=URL_ENDPOINT, class_time_list=CLASS_TIME, session=MemoryStorage): school = { 'code': code, 'lan_url': lan_url, 'proxies': proxies, 'timeout': timeout, 'name': to_text(name), 'login_url': login_url_path, 'url_endpoint': url_endpoint, 'exist_verify': exist_verify, 'use_ex_handle': use_ex_handle, 'priority_proxy': priority_proxy, 'time_list': get_time_list(class_time_list) } self.base_url = url.split('/default')[0] if url[-4:] == 'aspx' else url self.session = session(school['code']) self.school = ObjectDict(school)
def __init__(self, school_obj, account, password, user_type): self._http = requests.Session() self.school = school_obj.school self.base_url = school_obj.base_url self.session = school_obj.session self.user = ObjectDict({ 'account': to_text(account), 'password': password, 'user_type': user_type, 'proxy_state': False }) self._http.headers.update({ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/62.0.3202.89 Safari/537.36', 'Content-Type': 'application/x-www-form-urlencoded', 'Referer': self.base_url + self.school.login_url }) if self.school.priority_proxy: self.switch_proxy(True)
def __init__(self, url, **kwargs): url = url.split('/default')[0] if url[-4:] == 'aspx' else url class_time_list = kwargs.get('class_time_list') or CLASS_TIME time_list = get_time_list(class_time_list) self.school = { 'url': url, 'debug': kwargs.get('debug'), 'name': to_text(kwargs.get('name')), 'code': kwargs.get('code'), 'use_ex_handle': kwargs.get('use_ex_handle', True), 'exist_verify': kwargs.get('exist_verify', True), 'lan_url': kwargs.get('lan_url'), 'proxies': kwargs.get('proxies'), 'priority_proxy': kwargs.get('priority_proxy'), 'timeout': kwargs.get('timeout', 10), 'login_url': kwargs.get('login_url_path', '/default2.aspx'), 'url_endpoint': kwargs.get('url_endpoint') or URL_ENDPOINT, 'time_list': time_list } storage = kwargs.get('session', MemoryStorage) self.session = storage(self.school['code']) self.school = ObjectDict(self.school)