Fix crash with special characters

This commit is contained in:
Namhyeon Go 2024-06-17 08:43:52 +00:00
parent eca28a9095
commit f57385fe56

View File

@ -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)