=
commited on
Commit
·
a1d12d2
1
Parent(s):
f123cfb
fixed dependencie function
Browse files- deep_translator/linguee.py +3 -2
- deep_translator/pons.py +3 -2
deep_translator/linguee.py
CHANGED
@@ -3,7 +3,7 @@ from deep_translator.exceptions import LanguageNotSupportedException, ElementNot
|
|
3 |
from deep_translator.parent import BaseTranslator
|
4 |
from bs4 import BeautifulSoup
|
5 |
import requests
|
6 |
-
from requests.utils import
|
7 |
|
8 |
|
9 |
class LingueeTranslator(BaseTranslator):
|
@@ -51,7 +51,8 @@ class LingueeTranslator(BaseTranslator):
|
|
51 |
|
52 |
if self._validate_payload(word):
|
53 |
# %s-%s/translation/%s.html
|
54 |
-
url = "{}{}-{}/translation/{}.html".format(self.__base_url, self._source, self._target,
|
|
|
55 |
response = requests.get(url)
|
56 |
soup = BeautifulSoup(response.text, 'html.parser')
|
57 |
elements = soup.find_all(self._element_tag, self._element_query)
|
|
|
3 |
from deep_translator.parent import BaseTranslator
|
4 |
from bs4 import BeautifulSoup
|
5 |
import requests
|
6 |
+
from requests.utils import requote_uri
|
7 |
|
8 |
|
9 |
class LingueeTranslator(BaseTranslator):
|
|
|
51 |
|
52 |
if self._validate_payload(word):
|
53 |
# %s-%s/translation/%s.html
|
54 |
+
url = "{}{}-{}/translation/{}.html".format(self.__base_url, self._source, self._target, word)
|
55 |
+
url = requote_uri(url)
|
56 |
response = requests.get(url)
|
57 |
soup = BeautifulSoup(response.text, 'html.parser')
|
58 |
elements = soup.find_all(self._element_tag, self._element_query)
|
deep_translator/pons.py
CHANGED
@@ -4,7 +4,7 @@ import requests
|
|
4 |
from deep_translator.constants import BASE_URLS, PONS_LANGUAGES_TO_CODES, PONS_CODES_TO_LANGUAGES
|
5 |
from deep_translator.exceptions import LanguageNotSupportedException, ElementNotFoundInGetRequest, NotValidPayload
|
6 |
from deep_translator.parent import BaseTranslator
|
7 |
-
from requests.utils import
|
8 |
|
9 |
|
10 |
class PonsTranslator(BaseTranslator):
|
@@ -55,7 +55,8 @@ class PonsTranslator(BaseTranslator):
|
|
55 |
def translate(self, word, **kwargs):
|
56 |
|
57 |
if self._validate_payload(word):
|
58 |
-
url = "{}{}-{}/{}".format(self.__base_url, self._source, self._target,
|
|
|
59 |
response = requests.get(url)
|
60 |
soup = BeautifulSoup(response.text, 'html.parser')
|
61 |
elements = soup.findAll(self._element_tag, self._element_query)
|
|
|
4 |
from deep_translator.constants import BASE_URLS, PONS_LANGUAGES_TO_CODES, PONS_CODES_TO_LANGUAGES
|
5 |
from deep_translator.exceptions import LanguageNotSupportedException, ElementNotFoundInGetRequest, NotValidPayload
|
6 |
from deep_translator.parent import BaseTranslator
|
7 |
+
from requests.utils import requote_uri
|
8 |
|
9 |
|
10 |
class PonsTranslator(BaseTranslator):
|
|
|
55 |
def translate(self, word, **kwargs):
|
56 |
|
57 |
if self._validate_payload(word):
|
58 |
+
url = "{}{}-{}/{}".format(self.__base_url, self._source, self._target, word)
|
59 |
+
url = requote_uri(url)
|
60 |
response = requests.get(url)
|
61 |
soup = BeautifulSoup(response.text, 'html.parser')
|
62 |
elements = soup.findAll(self._element_tag, self._element_query)
|