Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -54,12 +54,12 @@ def translate(text,lang):
|
|
54 |
'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',
|
55 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
56 |
]
|
|
|
57 |
|
58 |
-
url
|
59 |
-
|
60 |
resp = requests.get(
|
61 |
url = url,
|
62 |
-
params = {'q': f'{lang} translate {text}'.replace(" ","%20")},
|
63 |
headers = {
|
64 |
'User-Agent': random.choice(user_agents)
|
65 |
}
|
@@ -71,7 +71,7 @@ def translate(text,lang):
|
|
71 |
translated = text
|
72 |
|
73 |
try:
|
74 |
-
src_lang = html.xpath('//span[@class="source-language"]
|
75 |
trgt_lang = html.xpath('//span[@class="target-language"]')[0].text_content().strip()
|
76 |
src_text = html.xpath('//pre[@id="tw-source-text"]/span')[0].text_content().strip()
|
77 |
trgt_text = html.xpath('//pre[@id="tw-target-text"]/span')[0].text_content().strip()
|
|
|
54 |
'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',
|
55 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
56 |
]
|
57 |
+
url = 'https://www.google.com/search?q=english%20translate%20'+text.replace(" ","%20")
|
58 |
|
59 |
+
print(url)
|
60 |
+
|
61 |
resp = requests.get(
|
62 |
url = url,
|
|
|
63 |
headers = {
|
64 |
'User-Agent': random.choice(user_agents)
|
65 |
}
|
|
|
71 |
translated = text
|
72 |
|
73 |
try:
|
74 |
+
src_lang = html.xpath('//span[@class="source-language"]')[0].text_content().strip()
|
75 |
trgt_lang = html.xpath('//span[@class="target-language"]')[0].text_content().strip()
|
76 |
src_text = html.xpath('//pre[@id="tw-source-text"]/span')[0].text_content().strip()
|
77 |
trgt_text = html.xpath('//pre[@id="tw-target-text"]/span')[0].text_content().strip()
|