(self, query_text:str, from_language:str='auto', to_language:str='en', **kwargs)
return data if is_detail_result else data['text'][0]
https://translate.yandex.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://translate.yandex.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 : // translate . yandex . 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 yandex_api(self, query_text:str, from_language:str='auto', to_language:str='en', **kwargs) -> Union[str,dict]:
        """
        https://translate.yandex.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:
            host_html = ss.get(self.host_url, headers=self.host_headers, timeout=timeout, proxies=proxies).text
            if not self.sid:
                sid_find = re.compile("SID: '(.*?)',").findall(host_html)
                self.sid = sid_find[0] if sid_find else '3d58bd71.5f49c293.93b157d0.74722d74657874'
            if not self.language_map:
                self.language_map = self.get_language_map(host_html)

            from_language, to_language = self.check_language(from_language, to_language, self.language_map, output_zh=self.output_zh)
            from_language = self.detect_language(ss, query_text, self.sid, timeout, proxies) if from_language=='auto' else from_language
            params = {
                'id': f'{self.sid}-{self.query_count}-0',
                'lang': f'{from_language}-{to_language}',
                'srv': 'tr-text',
                'reason': 'auto',
                'format': 'text'
            }
            form_data = {'text': query_text, 'options': 4}
            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['text'][0]
def yandex_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 : host_html = ss . get ( self . host_url , headers = self . host_headers , timeout = timeout , proxies = proxies ) . text if not self . sid : sid_find = re . compile ( "SID: '(.*?)'," ) . findall ( host_html ) self . sid = sid_find [ 0 ] if sid_find else '3d58bd71.5f49c293.93b157d0.74722d74657874' if not self . language_map : self . language_map = self . get_language_map ( host_html ) from_language , to_language = self . check_language ( from_language , to_language , self . language_map , output_zh = self . output_zh ) from_language = self . detect_language ( ss , query_text , self . sid , timeout , proxies ) if from_language == 'auto' else from_language params = { 'id' : f'{self.sid}-{self.query_count}-0' , 'lang' : f'{from_language}-{to_language}' , 'srv' : 'tr-text' , 'reason' : 'auto' , 'format' : 'text' } form_data = { 'text' : query_text , 'options' : 4 } 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 [ 'text' ] [ 0 ]