コード例 #1
0
 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
コード例 #2
0
 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))
コード例 #3
0
    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
コード例 #4
0
 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))
コード例 #5
0
 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__())
コード例 #6
0
 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__())
コード例 #7
0
    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 {}
コード例 #8
0
 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))
コード例 #9
0
 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))
コード例 #10
0
 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
コード例 #11
0
    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__())
コード例 #12
0
 def consoleDebug(self):
     for entry in self.__chromeDriver.get_log('browser'):
         __logger__.Print(0, __levels__.Info, entry)
コード例 #13
0
 def getNewAgent(self):
     agent = UserAgent(verify_ssl=False).random
     __logger__.Print(0, __levels__.Info, __texts__.getText(3).format(agent))
     return agent