I want to create a web scraper for earth.google.com/web. Whenever the user clicks while holding shift button, the script will print the coordinates which are displayed at the bottom right corner of the google earth web page.
I am using selenium with chromedriver but it cannot find the coordinates web element. I have tried css selector, xpath, full x-path, find by id. Nothing worked.
Here is my code:
import mouse
import keyboard
import time
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-logging"])
driver = webdriver.Chrome(options=options)
driver.get('https://earth.google.com/web')
while True:
if mouse.is_pressed(button='left') and keyboard.is_pressed('shift'):
coordinates = driver.find_elements_by_id('pointer-coordinates')
if len(coordinates) > 0:
print(coordinates[0].text)
else:
print('No coordinates found!')
time.sleep(0.2)