我如何在 selenium fireFox Python 上更改我在同一国家/地区的位置?

问题描述 投票:0回答:2

我想使用 Firefox Selenium 更改我在国内的位置,可以吗? 我在互联网上搜索了很多内容,但没有找到任何与此问题有关的内容,只是我不理解使用代理,但在不同国家/地区而不是柜台内的不同位置更改代理。

python-3.x selenium-webdriver geolocation selenium-firefoxdriver
2个回答
1
投票

我在使用 Selenium 编写功能测试时遇到了类似的问题。这是解决方案。

from selenium import webdriver

# geolocation supported, allowed and location mocked
ffOptions= webdriver.FirefoxOptions()
ffOptions.set_preference('geo.prompt.testing', True)
ffOptions.set_preference('geo.prompt.testing.allow', True)
ffOptions.set_preference('geo.provider.network.url','data:application/json,{"location": {"lat": 51.47, "lng": 0.0}, "accuracy": 100.0}')
browser = webdriver.Firefox(options=ffOptions)
webdriver.get('https://www.where-am-i.net/')

-1
投票

如果我们想更改我们自己的 IP 的位置,上面的解决方案将起作用,但如果我们想更改 Porxy 的 IP 的位置,那么如何在 python 中使用 selenium firefox webdriver...请给我建议

© www.soinside.com 2019 - 2024. All rights reserved.