简体   繁体   English

如果 firefoxbinary 设置为 webdriver.Firefox(firefox_profile=profile, firefox_binary=binary),则 firefoxprofile 不起作用

[英]firefoxprofile not working if firefoxbinary is set as webdriver.Firefox(firefox_profile=profile, firefox_binary=binary)

i noticed if i use firefox_binary within webdriver, the firefox_profile is not working.im getting my standard useragent我注意到如果我在 webdriver 中使用 firefox_binary,firefox_profile 不起作用。我正在获取我的标准用户代理

profile = FirefoxProfile(r".\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default")
binary = FirefoxBinary(r".\Tor Browser\Browser\firefox.exe")
ua = UserAgent()
userAgent = ua.random
profile = webdriver.FirefoxProfile()
profile.set_preference("general.useragent.override", userAgent)
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary)

but if use "driver = webdriver.Firefox(firefox_profile=profile)" i see the updated useragent but then normal firefox is opening with my standard ip但是如果使用“driver = webdriver.Firefox(firefox_profile=profile)”,我会看到更新的用户代理,但随后正常的 firefox 使用我的标准 ip 打开

What am i doing wrong?我究竟做错了什么? my os is on Windows 11 and python 3.9.9我的操作系统在 Windows 11 和 python 3.9.9

edit: i see, when im using the webdriver with firefox_binary right of address bar "not connected" but the website for example https://api.ipify.org is showing another IP always.编辑:我明白了,当我使用带有地址栏“未连接”右侧的 firefox_binary 的 webdriver 时,例如https://api.ipify.org的网站总是显示另一个 IP。 is that a problem?那是问题吗? if i use webdriver without firefox_binary is see nothing right of the address bar如果我在没有 firefox_binary 的情况下使用 webdriver,则在地址栏上什么也看不到

There is an issue that you are declaring profile as a variable twice:有一个问题是您将 profile 声明为变量两次:

profile = FirefoxProfile(r".\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default")

profile = webdriver.FirefoxProfile()

Amend to the following:修改如下:

prof = FirefoxProfile(r".\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default")

profile = webdriver.prof

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM