fake Geolocation in chrome automation(chrome自动化中的假地理位置)
问题描述
我需要使用 python 脚本在 chrome 中自动进行地理定位.我必须伪造纬度和经度.我关注了stackoverflow中的一些链接,但他们给出了错误.chromeDriver.executeScript("window.navigator.geolocation.getCurrentPosition=function(success){var position = {"coords" : {"latitude": "555","longitude": "999"}};success(position);}");
I need to automate geolocation in chrome using python script. I have to fake the latitude and longitude. I followed some links in stackoverflow but they gave errors. chromeDriver.executeScript("window.navigator.geolocation.getCurrentPosition=function(success){var position = {"coords" : {"latitude": "555","longitude": "999"}};success(position);}");
有没有其他方法可以改变位置?
is there any other way i can change the location?
推荐答案
在 Selenium 3.141 和 ChromeDriver 83.0 中使用 Python
Using Python with Selenium 3.141 and ChromeDriver 83.0
这是我找到的工作方法:
This is the working method I found:
params = {
"latitude": 34.0207305,
"longitude": -118.6919153,
"accuracy": 100
}
driver.execute_cdp_cmd("Emulation.clearGeolocationOverride", params)
这篇关于chrome自动化中的假地理位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:chrome自动化中的假地理位置


基础教程推荐
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 包装空间模型 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01