Python - Google Translate your own way, a.k.a hacking

preview_player
Показать описание
This video shows you how you can write your own translator script in python that leverages the Google Translate site. This is not the API way of using it, but the other more hackish way in which the selenium project is used to drive a browser, load the site, send the stuff to be translated and pick up the results.

Рекомендации по теме
Комментарии
Автор

this is really my 1st time leaving comment in Youtube. i would like to thank for your tutorial. although i am not doing exactly the way you did (cos i am too fresh for python and stuffs). but somehow i manage to use google translate page to do the translation. so i have to thank you for your video explanation.

jamcheung
Автор

Hi,
I get this error:
File "selenuim2.py", line 27, in <module>
TranslateButton = WebDriverWait(driver, 10).until(lambda driver:
File "C:\Users\Leader\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
Message:
....
is there any way for that code to work ?

mmengmm
Автор

Hello, does this still work? Is it possible to run this against a lot of JSON files? Or would Google block it after a few tries

ljeads
Автор

>python Trans.py --source-language en --destonation-language fr --tobetranslate "hello"
File "Trans.py", line 21
^
SyntaxError: invalid syntax




its showing me this error

prasadkatkade
Автор

The code as is did not work for me, I made a few tweaks, I commented out TranslateButton, this was no longer needed, as it detects words and automatically translates. I also changed the OutputElement path. Overall, great tutorial, and this method still works!

Code:
```
driver = webdriver.Firefox()


# TranslateButton = WebDriverWait(driver, 10).until(lambda driver:
InputBox = WebDriverWait(driver, 10).until(lambda driver:



# TranslateButton.click()

sleep(3)

ResultElement = WebDriverWait(driver, 10).until(lambda driver:
# import pdb; pdb.set_trace()
print(f"#### Result <{source_language}> -> <{destination_language}>")
print(ResultElement.text)
print("####")

driver.quit()
```

andrewdodd