daijro / camoufox

🦊 Undetected web scraping browser
https://camoufox.com
Mozilla Public License 2.0
98 stars 8 forks source link

How to set locale (Avoiding BrowserScan language mismatch) #16

Closed satanmp closed 2 weeks ago

satanmp commented 3 weeks ago

I have set language, languages, and screen, but I still can’t pass the test.can you help me? thanks code: config["navigator.language"] = 'zh-CN' config["navigator.languages"] = ['zh-CN', 'zh', 'zh-TW', 'zh-HK', 'en-US', 'en'] config["headers.User-Agent"] = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0' config["headers.Accept-Language"] = "zh-CN,zh;q=0.9" config["headers.Accept-Encoding"] = "gzip, deflate, br" config["screen.height"] = 900 config["screen.width"] = 1440 image

daijro commented 3 weeks ago

Hello, to set your browser locale, set the intl.accept_languages preference to zh-CN, zh:

from camoufox.sync_api import Camoufox

with Camoufox(firefox_user_prefs={"intl.accept_languages": "zh-CN, zh"}) as browser:
    page = browser.new_page()
    page.goto("https://www.browserscan.net/")
daijro commented 3 weeks ago

Sorry if it was difficult to find, I'll add a parameter to the Python interface to make it easier to set all the locale properties.

satanmp commented 3 weeks ago

Sorry if it was difficult to find, I'll add a parameter to the Python interface to make it easier to set all the locale properties.

There is no documentation, it is really not easy to set up, thank you

daijro commented 3 weeks ago

Reopening because there seems to sometimes be a mismatch between the system locale & browser locale.

To anyone looking through this issue, the solution I shared above works temporarily if your system is using the same locale as the one you're setting to intl.accept_languages, but it will leak if your system locale is different.

This is a simple fix and should be out in beta.8 by tomorrow.

Update:

System locale spoofing has been added in my local changes, but I'm having some issues with Intl api leaks. Going to be taking a break for 2 days to study for midterms.

tobwen commented 3 weeks ago

Going to be taking a break for 2 days to study for midterms.

I wish you all the best for this.

daijro commented 2 weeks ago

Hello,

Locale spoofing has been added in v130.0.1-beta.8, and the latest Python library update :+1: