Yaron Koresh commited on
Commit
83d3e5a
·
verified ·
1 Parent(s): 84291d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -46,10 +46,11 @@ def translate(text,lang):
46
  print(resp)
47
  content = resp.content
48
  html = fromstring(content)
49
- rslt = html.xpath('//span[@lang]')
50
- print(rslt)
51
  translated = rslt[0].text.strip()
52
- return re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
 
 
53
 
54
  def generate_random_string(length):
55
  characters = string.ascii_letters + string.digits
 
46
  print(resp)
47
  content = resp.content
48
  html = fromstring(content)
49
+ rslt = html.xpath('//pre[@aria-label="Translated text"]/span')
 
50
  translated = rslt[0].text.strip()
51
+ ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
52
+ print(ret)
53
+ return ret
54
 
55
  def generate_random_string(length):
56
  characters = string.ascii_letters + string.digits