fake Geolocation in chrome automation

前端 未结 4 1883
别跟我提以往
别跟我提以往 2021-01-16 23:07

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.

4条回答
  •  情书的邮戳
    2021-01-16 23:37

    It's actually now progammable by using the Chrome Devtools Protocol (cdp):

    params = {
        "latitude": 50.1109,
        "longitude": 8.6821,
        "accuracy": 100
    }
    
    self.driver = webdriver.Chrome()
    self.driver.execute_cdp_cmd("Page.setGeolocationOverride", params)
    self.driver.get('https://www.google.com/maps')
    

提交回复
热议问题