def parseText(self, fileName) -> str: captchaCode = pytesseract.image_to_string(Image.open(fileName), config='--psm 7') captchaCode.encode(__localSettings__.DEFAULT_ENCODING).decode( __localSettings__.DEFAULT_ENCODING).strip() if captchaCode != "": __logger__.Print(0, __levels__.Success, __texts__.getText(4).format(captchaCode)) else: __logger__.Print(5, __levels__.Success) return captchaCode
def TO(cls, jsData: str): try: if jsData != "": return cls(**json.loads(jsData)) else: return cls(**{'USERNAME': '******', 'PASSWORD': '******'}) except KeyError as KeyErr: __logger__.Print(0, __levels__.Error, str(KeyErr))
def getValueOf(self, key: str): for _key in self.__args.keys(): if _key == key: return self.__args[_key] __logger__.Print(0, level=__levels__.Warning, message=__texts__.getText(10).format(key)) return self.__EMPTY
def TO(cls, jsData: str): try: if jsData != "": return cls(**json.loads(jsData)) else: return cls(**{'FirstName': 'empty', 'LastName': 'empty', 'Email': 'empty', 'Password': '******', 'BirthMonth': 'empty', 'BirthDay': 'empty', 'BirthYear': 'empty', 'Gender': 'empty', 'PhoneNumber': 'empty', 'Desktop': 'empty'}) except KeyError as KeyErr: __logger__.Print(0, __levels__.Error, str(KeyErr))
def __init__(self, FirstName: str, LastName: str, Email: str, Password:str, BirthMonth: str, BirthDay: str, BirthYear: str, Gender: str, PhoneNumber: str = "", Desktop: bool = True): self.FirstName = FirstName self.LastName = LastName self.Email = Email self.Password = Password self.BirthMonth = BirthMonth self.BirthDay = BirthDay self.BirthYear = BirthYear self.Gender = Gender self.PhoneNumber = PhoneNumber self.Desktop = Desktop __logger__.Print(0, __levels__.Info, self.__str__())
def __init__(self, FirstName: str, LastName: str, UserName: str, Password: str, SecurityHint: str = "", Desktop: bool = True): self.FirstName = FirstName self.LastName = LastName self.UserName = UserName self.Password = Password self.SecurityHint = SecurityHint self.Desktop = Desktop __logger__.Print(0, __levels__.Info, self.__str__())
def __DEBUG(self, target: WebElement, value: str) -> dict: try: identifier = self.__elementClosestIdentifier(target=target) elementTag = target.tag_name elementType = target.get_attribute('type') if target is not None: if value != "": if elementTag == "input" or elementTag == "textarea": if elementType == "password": value = self.passMask(value=value) message = __texts__.getText(1).format( identifier, value) return __logger__.Print(msg_num=0, level=__levels__.Info, message=message) else: message = __texts__.getText(2).format( identifier, elementTag) return __logger__.Print(msg_num=0, level=__levels__.Info, message=message) except StaleElementReferenceException: return {}
def TO(cls, jsData: str): try: if jsData != "": return cls(**json.loads(jsData)) else: return cls( **{ 'USERNAME': '******', 'FIRSTNAME': 'empty', 'LASTNAME': 'empty', 'LIVING_LOCATION': 'empty', 'JOINED_AT': 'empty' }) except KeyError as KeyErr: __logger__.Print(0, __levels__.Error, str(KeyErr))
def TO(cls, jsData: str): try: if jsData != "": return cls(**json.loads(jsData)) else: return cls( **{ 'FirstName': 'empty', 'LastName': 'empty', 'UserName': '******', 'Password': '******', 'SecurityHint': 'empty', 'Desktop': 'empty' }) except KeyError as KeyErr: __logger__.Print(0, __levels__.Error, str(KeyErr))
def doLogin(self) -> bool: if not self.isLogged(): enterEmail = self.browser.Elements.clickAndInput( self.browser.Elements.findElementByCss( self.__emailInputSelector), value=self.fbCredentials.username, interval=1) enterPassword = self.browser.Elements.clickAndInput( self.browser.Elements.findElementByCss( self.__passwordInputSelector), value=self.fbCredentials.password, interval=2) clickLogin = self.browser.Elements.clickAndInput( self.browser.Elements.findElementByCss( self.__submitButtonSelector), interval=2) flag = self.isLogged() if not flag: __logger__.Print(10, __levels__.Warning) sys.exit(1) return flag
def __init__(self, tor: bool = False, incognito: bool = False, headless: bool = False, cache_folder: str = "", appMode: str = "", generateUserAgent: bool = False, disablePasswordService: bool = False): """ Just initialize some chromedriver options variables to customize browser startup :param tor :param incognito: :param headless: :param cache_folder: """ self.tor = tor self.incognito = incognito self.headless = headless self.cache_folder = cache_folder self.appMode = appMode self.generateUserAgent = generateUserAgent self.disablePasswordService = disablePasswordService __logger__.Print(0, __levels__.Info, self.__str__())
def consoleDebug(self): for entry in self.__chromeDriver.get_log('browser'): __logger__.Print(0, __levels__.Info, entry)
def getNewAgent(self): agent = UserAgent(verify_ssl=False).random __logger__.Print(0, __levels__.Info, __texts__.getText(3).format(agent)) return agent