问题
I am trying to use the below code to convert a web page from Swedish to English language:
chrome_options.add_argument("--lang=en-US")
I also tried the below:
'profile.default_content_settings.images': 2,
'translate_whitelists': {
'se':'en',
'el':'en',
},
'translate':{'enabled':'True'},
'intl.accept_languages': 'en,en_US',
})
None of them worked. The code has to be in Python Selenium
回答1:
Try below code -
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
browser_locale = 'en'
chrome_driver_path = 'chromedriver.exe'
options = Options()
options.add_argument("--lang={}".format(browser_locale))
browser = webdriver.Chrome(executable_path=chrome_driver_path,
chrome_options=options)
browser.get('https://google.com/')
Make the changes as it suits you.
来源:https://stackoverflow.com/questions/63148114/convert-web-page-from-swedish-to-english-in-python-selenium