def process_text(self, text):
        """ send request with given text and get result """
        # escape base char
        text = text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
        # make xml request body
        soap_body = self.__create_xml_request(text)
        # make total request
        length = len(soap_body.encode('UTF-8')) if PY3 else len(soap_body)
        soap_request = self.SOAP_REQUEST.format(
            length=length, host=self.HOST, content=soap_body)

        if PY3:  # convert to bytes
            soap_request = soap_request.encode(self._encoding)

        # send request use soket
        connector = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        connector.settimeout(self._timeout)
        connector.connect((self.HOST, 80))
        connector.sendall(soap_request)
        # call for response
        response = b''
        buf = '0'
        while len(buf):
            buf = connector.recv(8192)
            response += buf
        connector.close()

        if PY3:  # convert to str
            response = response.decode()

        # parse response
        text_result = self.__parse_xml_response(response)
        # back replace and return
        return text_result.replace('&amp;', '&').replace('&lt;', '<').replace('&gt;', '>')
def process_text ( self , text ) : text = text . replace ( '&' , '&amp;' ) . replace ( '<' , '&lt;' ) . replace ( '>' , '&gt;' ) soap_body = self . __create_xml_request ( text ) length = len ( soap_body . encode ( 'UTF-8' ) ) if PY3 else len ( soap_body ) soap_request = self . SOAP_REQUEST . format ( length = length , host = self . HOST , content = soap_body ) if PY3 : soap_request = soap_request . encode ( self . _encoding ) connector = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) connector . settimeout ( self . _timeout ) connector . connect ( ( self . HOST , 80 ) ) connector . sendall ( soap_request ) response = b'' buf = '0' while len ( buf ) : buf = connector . recv ( 8192 ) response += buf connector . close ( ) if PY3 : response = response . decode ( ) text_result = self . __parse_xml_response ( response ) return text_result . replace ( '&amp;' , '&' ) . replace ( '&lt;' , '<' ) . replace ( '&gt;' , '>' )
send request with given text and get result