Change page language with python and Selenium

Asked

Viewed 131 times

0

I’m trying to make the web scraping on Amazon with python and Selenium, but I need to translate the page to English first.

This is my code:

from os import getcwd
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

option = Options()
option.set_headless(True)
w = webdriver.ChromeOptions()
prefs = {
  "translate_whitelists": {"es":"en"},
  "translate":{"enabled":"true"}
}
w.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(executable_path=f"{getcwd()}\chromedriver.exe")

url = input("Digite uma url da amazon: ")

driver.get(url)

The page is in Spanish, I saw a solution with the "add_experimental_option" here in stackoverflow, but it didn’t work, the page is still in Spanish.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.