Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -25,31 +25,32 @@ else:
|
|
25 |
pipe = pipe.to(device)
|
26 |
|
27 |
def translate(text,lang):
|
28 |
-
user_agents = [
|
29 |
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
30 |
-
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
31 |
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
32 |
-
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
33 |
-
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
34 |
-
'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',
|
35 |
-
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
36 |
-
]
|
37 |
resp = requests.post(
|
38 |
-
url = "https://www.bing.com/ttranslatev3",
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
)
|
54 |
print(resp)
|
55 |
jsn = resp.json()
|
|
|
25 |
pipe = pipe.to(device)
|
26 |
|
27 |
def translate(text,lang):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
resp = requests.post(
|
29 |
+
url = "https://www.bing.com/ttranslatev3?isVertical=1&&IG=13172331D0494B12ABFA8F4454EEB479&IID=translator.5026",
|
30 |
+
"referrer": "https://www.bing.com/translator?to=en",
|
31 |
+
"referrerPolicy": "origin-when-cross-origin",
|
32 |
+
"data": f"&fromLang=auto-detect&to={lang}}&token=cdkbEXg93_iQE28MFPv9ScrPY_fs2OAw&key=1722124106496&text={text}&tryFetchingGenderDebiasedTranslations=true",
|
33 |
+
"method": "POST",
|
34 |
+
"mode": "cors",
|
35 |
+
"credentials": "include"
|
36 |
+
"headers": {
|
37 |
+
"accept": "*/*",
|
38 |
+
"accept-language": "en-US,en;q=0.9,he;q=0.8,ha;q=0.7",
|
39 |
+
"content-type": "application/x-www-form-urlencoded",
|
40 |
+
"priority": "u=1, i",
|
41 |
+
"sec-ch-ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"",
|
42 |
+
"sec-ch-ua-arch": "\"x86\"",
|
43 |
+
"sec-ch-ua-bitness": "\"64\"",
|
44 |
+
"sec-ch-ua-full-version": "\"126.0.6478.185\"",
|
45 |
+
"sec-ch-ua-full-version-list": "\"Not/A)Brand\";v=\"8.0.0.0\", \"Chromium\";v=\"126.0.6478.185\", \"Google Chrome\";v=\"126.0.6478.185\"",
|
46 |
+
"sec-ch-ua-mobile": "?0",
|
47 |
+
"sec-ch-ua-model": "\"\"",
|
48 |
+
"sec-ch-ua-platform": "\"Windows\"",
|
49 |
+
"sec-ch-ua-platform-version": "\"10.0.0\"",
|
50 |
+
"sec-fetch-dest": "empty",
|
51 |
+
"sec-fetch-mode": "cors",
|
52 |
+
"sec-fetch-site": "same-origin"
|
53 |
+
}
|
54 |
)
|
55 |
print(resp)
|
56 |
jsn = resp.json()
|