Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ else:
|
|
25 |
pipe = pipe.to(device)
|
26 |
|
27 |
def translate(text,lang):
|
28 |
-
html_str = requests.get( url = "
|
29 |
tree = fromstring(html_str)
|
30 |
translated = tree.xpath('//span[@lang="'+lang+'"]/span/span/text()')[0]
|
31 |
return translated
|
|
|
25 |
pipe = pipe.to(device)
|
26 |
|
27 |
def translate(text,lang):
|
28 |
+
html_str = requests.get( url = "http://translate.google.com", params = {"sl": "auto", "tl": lang, "op": "translate", "text": text}, headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'} ).text
|
29 |
tree = fromstring(html_str)
|
30 |
translated = tree.xpath('//span[@lang="'+lang+'"]/span/span/text()')[0]
|
31 |
return translated
|