![](/img/trans.png)
[英]WebDriver Firefox profile not working after IEDriverServer setup
[英]firefoxprofile not working if firefoxbinary is set as webdriver.Firefox(firefox_profile=profile, firefox_binary=binary)
我注意到如果我在 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)
但是如果使用“driver = webdriver.Firefox(firefox_profile=profile)”,我會看到更新的用戶代理,但隨后正常的 firefox 使用我的標准 ip 打開
我究竟做錯了什么? 我的操作系統在 Windows 11 和 python 3.9.9
編輯:我明白了,當我使用帶有地址欄“未連接”右側的 firefox_binary 的 webdriver 時,例如https://api.ipify.org的網站總是顯示另一個 IP。 那是問題嗎? 如果我在沒有 firefox_binary 的情況下使用 webdriver,則在地址欄上什么也看不到
有一個問題是您將 profile 聲明為變量兩次:
profile = FirefoxProfile(r".\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default")
profile = webdriver.FirefoxProfile()
修改如下:
prof = FirefoxProfile(r".\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default")
profile = webdriver.prof
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.