Selenium change firefox browser language python mac

I spent 3 hours trying to find a solution to this problem, and I am so far from an answer, I feel that I have to ask. (I found similar posts - below explains why I ask, despite looking for these posts)

I am writing a program that introduces several search terms to Google - and gets my page rank. I want to know my rating for several different SERPs. I solved the problem with resolving the ip address. But now I see that Google uses factoring in the language of my browser, giving me SERP. To get closer to the true rank of my page in the country (I speak closer, because I also saw that SERP depends on the search history), I have to use a web browser with the native language in the country where I am interested.

Changing the language in firefox manually is difficult - in fact you need to install several different language versions (I also read about installing language packs, but I'm not sure if this applies to firefox 12). I do not know how to get selenium in order to select the correct version of firefox.

It’s hard for me to understand what needs to be done: whether it is necessary to specify which installer / version of the Firefox web driver.firefox(). to use when starting web driver.firefox(). Or you can determine the browser language by changing the firefox profile.

I spent some time looking at part of the profile - and found a partial proof (the original message), although I can not find the link to the language in the profile files.

The answer in the same message seems to have solved the problem, but I don’t know the language, and it’s hard for me to understand what is actually being done.

I know that add-on for firefox to switch between language versions (you must first install the different language versions of firefox what you want). Given that the "general.useragent.local preference" change is mentioned in the settings parameter, I think this is a profile parameter that can be changed, but to add it, you need to restart the browser when changing the language - so ..

I can not find anything about general.useragent.local in the profile settings.

Anyone who gives me a point in the right direction will make my day!

EDIT: Forgot to mention - I only know python - so why did I write python in the header

0
source share
1 answer

Ok, I have to agree that maybe this is not the best way to approach this problem, but will answer what you need

 from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary binary = FirefoxBinary('path/to/binary') profile = webdriver.FirefoxProfile() profile.add_extension('path/to/xpi') #XPI needs to be on disk and not downloaded from AMO profile.set_preference('general.useragent.local','<enter your value') driver = webdriver.Firefox(firefox_binary=binary, firefox_profile=profile) # Carry on with what you want 

Jackets are available here.

+3
source

Source: https://habr.com/ru/post/1437900/


All Articles