Yaron Koresh commited on
Commit
cda062e
·
verified ·
1 Parent(s): 44eb51d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
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 = "https://translate.google.com", params = {"sl": "auto", "tl": lang, "op": "translate", "text": text} ).text
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