Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -33,20 +33,27 @@ def translate(text,lang):
|
|
33 |
'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',
|
34 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
35 |
]
|
36 |
-
|
37 |
-
url = "https://www.bing.com/ttranslatev3
|
38 |
-
|
39 |
-
'
|
|
|
|
|
|
|
|
|
|
|
40 |
'to': lang,
|
41 |
-
'token': MLfPKZhAXMWZirPdlpeEfN8DB58dZKR
|
42 |
-
'key': 1722119087131,
|
43 |
-
'text': text
|
44 |
-
'tryFetchingGenderDebiasedTranslations': true
|
45 |
},
|
46 |
headers = {'User-Agent': random.choice(user_agents)}
|
47 |
-
)
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
return translated
|
51 |
|
52 |
def generate_random_string(length):
|
|
|
33 |
'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',
|
34 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
35 |
]
|
36 |
+
resp = requests.post(
|
37 |
+
url = "https://www.bing.com/ttranslatev3",
|
38 |
+
params = {
|
39 |
+
'isVertical': '1',
|
40 |
+
'IG': '25FEDD45BDB744CF85D101C01E6596C0',
|
41 |
+
'IID': 'translator.5026'
|
42 |
+
},
|
43 |
+
data = {
|
44 |
+
'fromLang': 'auto-detect',
|
45 |
'to': lang,
|
46 |
+
'token': 'MLfPKZhAXMWZirPdlpeEfN8DB58dZKR-',
|
47 |
+
'key': '1722119087131',
|
48 |
+
'text': text,
|
49 |
+
'tryFetchingGenderDebiasedTranslations': 'true'
|
50 |
},
|
51 |
headers = {'User-Agent': random.choice(user_agents)}
|
52 |
+
)
|
53 |
+
print(resp)
|
54 |
+
jsn = resp.json()
|
55 |
+
print(jsn)
|
56 |
+
translated = jsn[0]["translations"][0]["text"]
|
57 |
return translated
|
58 |
|
59 |
def generate_random_string(length):
|