mirror of
https://gitlab.com/gnh1201/pylingva.git
synced 2024-11-26 15:32:06 +00:00
Fix crash with special characters
This commit is contained in:
parent
eca28a9095
commit
f57385fe56
|
@ -1,5 +1,6 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
|
|
||||||
|
import urllib.parse
|
||||||
import requests as req
|
import requests as req
|
||||||
|
|
||||||
class pylingva:
|
class pylingva:
|
||||||
|
@ -35,6 +36,7 @@ class pylingva:
|
||||||
return lang
|
return lang
|
||||||
|
|
||||||
def translate(self, source, target, text):
|
def translate(self, source, target, text):
|
||||||
|
text = urllib.parse.quote(text, safe='')
|
||||||
url = f"{self.url}/{source}/{target}/{text}"
|
url = f"{self.url}/{source}/{target}/{text}"
|
||||||
url = url.replace("?", "%3F")
|
url = url.replace("?", "%3F")
|
||||||
r = req.get(url)
|
r = req.get(url)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user