【发布时间】:2022-01-18 19:48:17
【问题描述】:
我注意到如果我在webdriver 中使用firefox_binary,firefox_profile 不是working.im 得到我的标准useragent。
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)
但如果使用driver = webdriver.Firefox(firefox_profile=profile),我会看到更新后的用户代理,但正常的 Firefox 正在使用我的标准 ip 打开。
我做错了什么?
我的操作系统在 Windows 11 和 Python 3.9.9
我还看到,当我使用带有地址栏“未连接”的 firefox_binary 的 webdriver 时,但例如 https://api.ipify.org 的网站总是显示另一个 IP。那是问题吗?
如果我使用webdriver 而不使用firefox_binary,则在地址栏右侧什么也看不到。
【问题讨论】:
标签: python selenium user-agent tor selenium-firefoxdriver