Convert Web Page from Swedish to English in Python Selenium

狂风中的少年 提交于 2021-02-11 13:41:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!