(self, query_text:str, from_language:str='auto', to_language:str='en', **kwargs)
return data if is_detail_result else data['listTargetText'][0]
https://translate.alibaba.com
        :param query_text: str, must.
        :param from_language: str, default 'auto'.
        :param to_language: str, default 'en'.
        :param **kwargs:
                :param professional_field: str, default 'message', choose from ("general","message","offer")
                :param if_ignore_limit_of_length: boolean, default False.
                :param is_detail_result: boolean, default False.
                :param timeout: float, default None.
                :param proxies: dict, default None.
                :param sleep_seconds: float, default `random.random()`.
        :return: str or dict
https://translate.alibaba.com
        :param query_text: str, must.
        :param from_language: str, default 'auto'.
        :param to_language: str, default 'en'.
        :param **kwargs:
                :param professional_field: str, default 'message', choose from ("general","message","offer")
                :param if_ignore_limit_of_length: boolean, default False.
                :param is_detail_result: boolean, default False.
                :param timeout: float, default None.
                :param proxies: dict, default None.
                :param sleep_seconds: float, default `random.random()`.
        :return: str or dict
https : // translate . alibaba . com : param query_text : str must . : param from_language : str default auto . : param to_language : str default en . : param ** kwargs : : param professional_field : str default message choose from ( general message offer ) : param if_ignore_limit_of_length : boolean default False . : param is_detail_result : boolean default False . : param timeout : float default None . : param proxies : dict default None . : param sleep_seconds : float default random . random () . : return : str or dict
def alibaba_api(self, query_text:str, from_language:str='auto', to_language:str='en', **kwargs) -> Union[str,dict]:
        """
        https://translate.alibaba.com
        :param query_text: str, must.
        :param from_language: str, default 'auto'.
        :param to_language: str, default 'en'.
        :param **kwargs:
                :param professional_field: str, default 'message', choose from ("general","message","offer")
                :param if_ignore_limit_of_length: boolean, default False.
                :param is_detail_result: boolean, default False.
                :param timeout: float, default None.
                :param proxies: dict, default None.
                :param sleep_seconds: float, default `random.random()`.
        :return: str or dict
        """
        use_domain = kwargs.get('professional_field', 'message')
        assert use_domain in ("general","message","offer")
        is_detail_result = kwargs.get('is_detail_result', False)
        timeout = kwargs.get('timeout', None)
        proxies = kwargs.get('proxies', None)
        sleep_seconds = kwargs.get('sleep_seconds', random.random())
        if_ignore_limit_of_length = kwargs.get('if_ignore_limit_of_length', False)
        query_text = self.check_query_text(query_text, if_ignore_limit_of_length)
        
        with requests.Session() as ss:
            host_response = ss.get(self.host_url, headers=self.host_headers, timeout=timeout, proxies=proxies)
            dmtrack_pageid = self.get_dmtrack_pageid(host_response)
            if not self.language_map:
                 self.language_map = self.get_language_map(ss, use_domain, dmtrack_pageid, timeout, proxies)
            from_language, to_language = self.check_language(from_language, to_language, self.language_map, output_zh=self.output_zh)
            form_data = {
                "srcLanguage": from_language,
                "tgtLanguage": to_language,
                "srcText": query_text,
                "viewType": "",
                "source": "",
                "bizType": use_domain,
            }
            params = {"dmtrack_pageid":dmtrack_pageid}
            r = ss.post(self.api_url, headers=self.api_headers, params=params, data=form_data, timeout=timeout, proxies=proxies)
            r.raise_for_status()
            data = r.json()
        time.sleep(sleep_seconds)
        self.query_count += 1
        return data if is_detail_result else data['listTargetText'][0]
def alibaba_api ( self , query_text : str , from_language : str = 'auto' , to_language : str = 'en' , * * kwargs ) -> Union [ str , dict ] : use_domain = kwargs . get ( 'professional_field' , 'message' ) assert use_domain in ( "general" , "message" , "offer" ) is_detail_result = kwargs . get ( 'is_detail_result' , False ) timeout = kwargs . get ( 'timeout' , None ) proxies = kwargs . get ( 'proxies' , None ) sleep_seconds = kwargs . get ( 'sleep_seconds' , random . random ( ) ) if_ignore_limit_of_length = kwargs . get ( 'if_ignore_limit_of_length' , False ) query_text = self . check_query_text ( query_text , if_ignore_limit_of_length ) with requests . Session ( ) as ss : host_response = ss . get ( self . host_url , headers = self . host_headers , timeout = timeout , proxies = proxies ) dmtrack_pageid = self . get_dmtrack_pageid ( host_response ) if not self . language_map : self . language_map = self . get_language_map ( ss , use_domain , dmtrack_pageid , timeout , proxies ) from_language , to_language = self . check_language ( from_language , to_language , self . language_map , output_zh = self . output_zh ) form_data = { "srcLanguage" : from_language , "tgtLanguage" : to_language , "srcText" : query_text , "viewType" : "" , "source" : "" , "bizType" : use_domain , } params = { "dmtrack_pageid" : dmtrack_pageid } r = ss . post ( self . api_url , headers = self . api_headers , params = params , data = form_data , timeout = timeout , proxies = proxies ) r . raise_for_status ( ) data = r . json ( ) time . sleep ( sleep_seconds ) self . query_count += 1 return data if is_detail_result else data [ 'listTargetText' ] [ 0 ]