Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -35,14 +35,14 @@ def translate(text,lang):
|
|
35 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15',
|
36 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
37 |
]
|
38 |
-
resp = requests.
|
39 |
-
url = f
|
40 |
headers = {
|
41 |
'User-Agent': random.choice(user_agents)
|
42 |
}
|
43 |
)
|
44 |
print(resp)
|
45 |
-
translated = fromstring(resp.content).xpath('//
|
46 |
return re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
47 |
|
48 |
def generate_random_string(length):
|
|
|
35 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15',
|
36 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
37 |
]
|
38 |
+
resp = requests.get(
|
39 |
+
url = f'https://www.google.com/search?q=translate%20to%20{lang}:{text}'
|
40 |
headers = {
|
41 |
'User-Agent': random.choice(user_agents)
|
42 |
}
|
43 |
)
|
44 |
print(resp)
|
45 |
+
translated = fromstring(resp.content).xpath('//span[@lang')[0].text().strip()
|
46 |
return re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
47 |
|
48 |
def generate_random_string(length):
|