(self, query_text:str, from_language:str='zh', to_language:str='en', **kwargs)
return data if is_detail_result else data['data']['result']['trans_result']['dst']
https://saas.xfyun.cn/translate?tabKey=text
        :param query_text: str, must.
        :param from_language: str, default 'zh', unsupported '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://saas.xfyun.cn/translate?tabKey=text
        :param query_text: str, must.
        :param from_language: str, default 'zh', unsupported '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 : // saas . xfyun . cn / translate?tabKey = text : param query_text : str must . : param from_language : str default zh unsupported 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 iflytek_api(self, query_text:str, from_language:str='zh', to_language:str='en', **kwargs) -> Union[str,dict]:
        """
        https://saas.xfyun.cn/translate?tabKey=text
        :param query_text: str, must.
        :param from_language: str, default 'zh', unsupported '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)
        delete_temp_language_map_label = 0
        assert from_language != 'auto', 'unsupported [from_language=auto] with [iflytek] !'

        with requests.Session() as ss:
            host_html = ss.get(self.host_url, headers=self.host_headers, timeout=timeout, proxies=proxies).text
            _ = ss.get(self.cookies_url, headers=self.host_headers, timeout=timeout, proxies=proxies)
            _ = ss.get(self.info_url, headers=self.host_headers, timeout=timeout, proxies=proxies)
            if not self.language_map:
                self.language_map = self.get_language_map(host_html, ss, self.host_headers, timeout, proxies)
            if not self.language_map:
                delete_temp_language_map_label += 1
                self.language_map = self.make_temp_language_map(from_language, to_language)
            from_language, to_language = self.check_language(from_language, to_language, self.language_map, output_zh=self.output_zh)

            cookie_dict = ss.cookies.get_dict()
            self.api_headers.update({'Cookie': f'_wafuid={cookie_dict["_wafuid"]}; di_c_mti={cookie_dict["SESSION"]}'})

            cipher_query_text = base64.b64encode(query_text.encode()).decode()
            form_data = {'from': from_language, 'to': to_language, 'text': cipher_query_text}
            r = ss.post(self.api_url, headers=self.api_headers, data=form_data, timeout=timeout, proxies=proxies)
            r.raise_for_status()
            data = r.json()

        if delete_temp_language_map_label != 0:
            self.language_map = None
        time.sleep(sleep_seconds)
        self.query_count += 1
        return data if is_detail_result else data['data']['result']['trans_result']['dst']
def iflytek_api ( self , query_text : str , from_language : str = 'zh' , 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 ) delete_temp_language_map_label = 0 assert from_language != 'auto' , 'unsupported [from_language=auto] with [iflytek] !' with requests . Session ( ) as ss : host_html = ss . get ( self . host_url , headers = self . host_headers , timeout = timeout , proxies = proxies ) . text _ = ss . get ( self . cookies_url , headers = self . host_headers , timeout = timeout , proxies = proxies ) _ = ss . get ( self . info_url , headers = self . host_headers , timeout = timeout , proxies = proxies ) if not self . language_map : self . language_map = self . get_language_map ( host_html , ss , self . host_headers , timeout , proxies ) if not self . language_map : delete_temp_language_map_label += 1 self . language_map = self . make_temp_language_map ( from_language , to_language ) from_language , to_language = self . check_language ( from_language , to_language , self . language_map , output_zh = self . output_zh ) cookie_dict = ss . cookies . get_dict ( ) self . api_headers . update ( { 'Cookie' : f'_wafuid={cookie_dict["_wafuid"]}; di_c_mti={cookie_dict["SESSION"]}' } ) cipher_query_text = base64 . b64encode ( query_text . encode ( ) ) . decode ( ) form_data = { 'from' : from_language , 'to' : to_language , 'text' : cipher_query_text } r = ss . post ( self . api_url , headers = self . api_headers , data = form_data , timeout = timeout , proxies = proxies ) r . raise_for_status ( ) data = r . json ( ) if delete_temp_language_map_label != 0 : self . language_map = None time . sleep ( sleep_seconds ) self . query_count += 1 return data if is_detail_result else data [ 'data' ] [ 'result' ] [ 'trans_result' ] [ 'dst' ]