Yaron Koresh commited on
Commit
a597e6b
·
verified ·
1 Parent(s): 5b52e9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -15
app.py CHANGED
@@ -25,26 +25,21 @@ else:
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
  data = f"&fromLang=auto-detect&to={lang}&token=cdkbEXg93_iQE28MFPv9ScrPY_fs2OAw&key=1722124106496&text={text}&tryFetchingGenderDebiasedTranslations=true",
31
  headers = {
32
- "accept": "*/*",
33
- "accept-language": "en-US,en;q=0.9,he;q=0.8,ha;q=0.7",
34
  "content-type": "application/x-www-form-urlencoded",
35
- "priority": "u=1, i",
36
- "sec-ch-ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"",
37
- "sec-ch-ua-arch": "\"x86\"",
38
- "sec-ch-ua-bitness": "\"64\"",
39
- "sec-ch-ua-full-version": "\"126.0.6478.185\"",
40
- "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\"",
41
- "sec-ch-ua-mobile": "?0",
42
- "sec-ch-ua-model": "\"\"",
43
- "sec-ch-ua-platform": "\"Windows\"",
44
- "sec-ch-ua-platform-version": "\"10.0.0\"",
45
- "sec-fetch-dest": "empty",
46
- "sec-fetch-mode": "cors",
47
- "sec-fetch-site": "same-origin"
48
  }
49
  )
50
  print(resp)
 
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?isVertical=1&&IG=13172331D0494B12ABFA8F4454EEB479&IID=translator.5026",
39
  data = f"&fromLang=auto-detect&to={lang}&token=cdkbEXg93_iQE28MFPv9ScrPY_fs2OAw&key=1722124106496&text={text}&tryFetchingGenderDebiasedTranslations=true",
40
  headers = {
 
 
41
  "content-type": "application/x-www-form-urlencoded",
42
+ 'User-Agent': random.choice(user_agents)
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
  )
45
  print(resp)