def __login(self): try: """ ### 再次尝试 1.因为网络问题重试 ### 重新注册 2.因为账户被封重试 3.因为账户认证错误重试 """ warning(f"Login -> [{self.usr}:{self.pwd}]") self.__login_payload.update({ "password": self.pwd, "username": self.usr }) resp = self.__refresh_new_target( self.session.post( self.__login_url, data=self.__login_payload, verify=False, timeout=120, )) if self.usr in resp.text and "暗网欢迎您" in resp.text: success("Auth Success") self.types = Parser.get_current_type(resp) # assert self.types != {} else: error(f"Auth Faild: {self.__clean_log(resp)}") self.__save_error("__login.html", resp) if "已被封禁" in resp.text: Cursor.ban_user(self.usr) self.__reg() raise ValueError except KeyboardInterrupt: exit()
def login(self): try: """ ### 再次尝试 1.因为网络问题重试 ### 重新注册 2.因为账户被封重试 3.因为账户认证错误重试 """ warning(f"login -> [{self.usr}:{self.pwd}]") self.login_payload.update({ "password": self.pwd, "username": self.usr }) resp = self.session.post( self.login_url, data=self.login_payload, headers={ "Content-Type": "application/x-www-form-urlencoded", "Referer": f"http://{self.domain}/ucp.php?mode=login", }, allow_redirects=False, ) debug(f"login[1] requests header: {resp.request.headers}") debug(f"login[1] response header: {resp.headers}") if resp.status_code == 302 and "Location" in resp.headers: resp = self.refresh_new_target( self.session.get( resp.headers.get("Location"), headers={ "Referer": f"http://{self.domain}/ucp.php?mode=login&sid={self.sid}", "Cookie": self.get_cookie_string(), }, )) else: Cursor.ban_user(self.usr) self.update_random_user() return debug(f"login[2] requests header: {resp.request.headers}") debug(f"login[2] response header: {resp.headers}") if self.usr in resp.text and "暗网欢迎您" in resp.text: success("Auth Success") self.types = Parser.get_current_type(resp) else: error(f"Auth Faild: {self.clean_log(resp)}") if re.findall("已被封禁|无效的|违规被处理", resp.text): Cursor.ban_user(self.usr) self.update_random_user() # if not self.register(): # return # else: # raise ValueError except KeyboardInterrupt: exit()
def __login(self): try: """ ### 再次尝试 1.因为网络问题重试 ### 重新注册 2.因为账户被封重试 3.因为账户认证错误重试 """ warning(f"Login -> [{self.usr}:{self.pwd}]") self.__login_payload.update({"password": self.pwd, "username": self.usr}) resp = self.__refresh_new_target( self.session.post( self.__login_url, data=self.__login_payload, verify=False, timeout=120, # headers={ # "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", # "Accept-Encoding": "gzip, deflate", # "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", # "Cache-Control": "no-cache", # "DNT": "1", # "Host": self.__domain, # "Pragma": "no-cache", # "Origin":self.__main_url, # "Referer": f"{self.__main_url}/ucp.php?mode=login&autim={self.__login_payload['autim']}", # "Upgrade-Insecure-Requests": "1", # "User-Agent": "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0" # } ) ) debug(resp.history) debug(resp.request.headers) if self.usr in resp.text and "暗网欢迎您" in resp.text: success("Auth Success") self.types = Parser.get_current_type(resp) # assert self.types != {} else: error(f"Auth Faild: {self.__clean_log(resp)}") self.__save_error("__login.html", resp) if "已被封禁" in resp.text: Cursor.ban_user(self.usr) self.__reg() raise ValueError except KeyboardInterrupt: exit()