(self, query_text:str, from_language:str='auto', to_language:str='en', **kwargs)
return data if is_detail_result else ''.join(item['targetText'] for item in data['translate']['records'])
https://fanyi.qq.com
        :param query_text: str, must.
        :param from_language: str, default 'auto'.
        :param to_language: str, default 'en'.
        :param **kwargs:
                :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://fanyi.qq.com
        :param query_text: str, must.
        :param from_language: str, default 'auto'.
        :param to_language: str, default 'en'.
        :param **kwargs:
                :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 : // fanyi . qq . com : param query_text : str must . : param from_language : str default auto . : param to_language : str default en . : param ** kwargs : : 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 tencent_api(self, query_text:str, from_language:str='auto', to_language:str='en', **kwargs) -> Union[str,dict]:
        """
        https://fanyi.qq.com
        :param query_text: str, must.
        :param from_language: str, default 'auto'.
        :param to_language: str, default 'en'.
        :param **kwargs:
                :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
        """
        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:
            _ = ss.get(self.host_url, headers=self.host_headers, timeout=timeout, proxies=proxies).text
            if not self.language_map:
                self.language_map = self.get_language_map(ss, self.get_language_url, timeout, proxies)
            from_language, to_language = self.check_language(from_language, to_language, self.language_map, output_zh=self.output_zh)
            self.qtv_qtk = self.get_qt(ss, timeout, proxies, if_session=False)
            form_data = {
                'source': from_language,
                'target': to_language,
                'sourceText': query_text,
                'qtv': self.qtv_qtk.get('qtv', ''),
                'qtk': self.qtv_qtk.get('qtk', ''),
                'ticket': '',
                'randstr': '',
                'sessionUuid': 'translate_uuid' + str(int(time.time()*1000)),
            }
            r = ss.post(self.api_url, headers=self.api_headers, 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 ''.join(item['targetText'] for item in data['translate']['records'])
def tencent_api ( self , query_text : str , from_language : str = 'auto' , to_language : str = 'en' , * * kwargs ) -> Union [ str , dict ] : 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 : _ = ss . get ( self . host_url , headers = self . host_headers , timeout = timeout , proxies = proxies ) . text if not self . language_map : self . language_map = self . get_language_map ( ss , self . get_language_url , timeout , proxies ) from_language , to_language = self . check_language ( from_language , to_language , self . language_map , output_zh = self . output_zh ) self . qtv_qtk = self . get_qt ( ss , timeout , proxies , if_session = False ) form_data = { 'source' : from_language , 'target' : to_language , 'sourceText' : query_text , 'qtv' : self . qtv_qtk . get ( 'qtv' , '' ) , 'qtk' : self . qtv_qtk . get ( 'qtk' , '' ) , 'ticket' : '' , 'randstr' : '' , 'sessionUuid' : 'translate_uuid' + str ( int ( time . time ( ) * 1000 ) ) , } r = ss . post ( self . api_url , headers = self . api_headers , 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 '' . join ( item [ 'targetText' ] for item in data [ 'translate' ] [ 'records' ] )