Get an English translation using python google translate selenium (memories)

There are various ways to translate Google. I tried to translate automatically by referring to this link.


from bs4 import BeautifulSoup
from selenium import webdriver
import urllib.parse

driver = webdriver.Chrome(r"C:\Users\xxxxxxxx\xxxxx\study\chromedriver.exe")
text = "It's sunny today."
url_text = "https://translate.google.co.jp/#ja/en/{0}".format(text)
url = urllib.parse.quote_plus(url_text, "/:?=&#")
driver.get(url)
html = driver.page_source
result = BeautifulSoup(html, "html.parser").find(class_="tlid-translation translation").text

print(result)

driver.close()
driver.quit()

Translated as It is sunny today. I think It's fine today. Is correct, but it works.

Recommended Posts

Get an English translation using python google translate selenium (memories)
[Python] Easy Google Translate app using Eel and Googletrans
[Python] Get insight data using Google My Business API
Get and automate ASP Datepicker control using Python and Selenium
Automatically translate DeepL into English with Python and Selenium
Inflating text data by retranslation using google translate in Python
Start to Selenium using python
Web scraping using Selenium (Python)
Translate using googletrans in Python
Get and set the value of the dropdown menu using Python and Selenium
[Python] Simple Japanese ⇒ I tried to make an English translation tool
[Python] Hit the Google Translation API
Forcibly use Google Translate from python
Selenium and python to open google
Python> dictionary> values ()> Get All Values by Using values ()
Get html from element with Python selenium
Get Suica balance in Python (using libpafe)
Get tweets containing keywords using Python Tweepy
[Beginner] Python web scraping using Google Colaboratory
Get Google Fit API data in Python
Try using Python with Google Cloud Functions
Get Twitter bookmarks on CentOS using Selenium
Get Youtube data in Python using Youtube Data API
Reboot the router using Python, Selenium, PhantomJS
Create an English word app with python
Creating Google Spreadsheet using Python / Google Data API
Python programming: I tried to get (crawling) news articles using Selenium and BeautifulSoup4.
I tried using Google Translate from Python and it was just too easy