Code Monkey home page Code Monkey logo

Comments (4)

Animenosekai avatar Animenosekai commented on May 28, 2024 1

Great @Animenosekai ! I read the code from translatepy\utils\request.py And as you said, it will change the proxy ip on each request. So, I supose this issue is solved.

if self._proxies_index != len(self.proxies) - 1:
    self._proxies_index += 1
else:
    self._proxies_index = 0

Thank you!

Btw it is recommended to use the Translator class instead of just the DeeplTranslate one, (you could pass the DeeplTranslate class first in Translator if you want their answer first and add the other ones to fallback like so:

>>> from translatepy.translators import GoogleTranslate, DeeplTranslate, ReversoTranslate, BingTranslate
>>> from translatepy import Translate
>>> from translatepy.utils.request import Request
>>>
>>> translator = Translate(services_list=[DeeplTranslate, GoogleTranslate, BingTranslate, ReversoTranslate], request=Request(proxy_urls=["<proxy_one>", "<proxy_two>"]))
>>>
>>> translator.translate("Hello", "Japanese")
TranslationResult(service=DeepL, source=Hello, source_language=jpn, destination_language=jpn, result=Hello)

)

from translate.

Animenosekai avatar Animenosekai commented on May 28, 2024

translate_html was primarily designed for the Translate class but now that you mention it I could add a parameter to use a blocking method

without being blocked

No DeepL has way too strict rate limits and no one has found a solution to this issue

from translate.

Animenosekai avatar Animenosekai commented on May 28, 2024

@davidmartinrius Thinking about it, you just need to pass threads_limit=1 to process in only one thread.

Also, Request() changes to the next proxy on each request, so it will change to a different proxy in each thread.

from translate.

davidmartinrius avatar davidmartinrius commented on May 28, 2024

Great @Animenosekai !
I read the code from translatepy\utils\request.py And as you said, it will change the proxy ip on each request.
So, I supose this issue is solved.

if self._proxies_index != len(self.proxies) - 1:
    self._proxies_index += 1
else:
    self._proxies_index = 0

Thank you!

from translate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.