I'm testing this simple code. It gets me to the lat & lon coordinates and zooms in to the point I want.
UPDATED CODE:
import pandas as pd
df_fin = pd.read_csv('C:\\Users\\df_fin.csv')
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver
import time
driver = webdriver.Chrome('C:\\Users\\TryMe\\chromedriver.exe')
driver.maximize_window()
driver.implicitly_wait(5)
i = 1
for item in df_fin['place']:
try:
driver.get(item)
wait = WebDriverWait(driver, 10)
main_canvas = wait.until(EC.element_to_be_clickable((By.XPATH, "//*[name()='canvas']")))
size = main_canvas.size
w, h = size['width'], size['height']
new_w = w/2
new_h = h/2
ActionChains(driver).move_by_offset(new_h, new_h).pause(5).perform()
time.sleep(2)
wait.until(EC.element_to_be_clickable((By.XPATH, "//*[name()='canvas']"))).click()
print(driver.title)
df_fin['my_place'] = driver.title
except:
df_fin['my_place'] = 'OTHER'
i = i + 1
print(i)
df_fin.head(10)
That gives me this. The title says 'Google Maps'.
If I click the middle of the screen, I get this.
Now the title says 'Rod Laver Arena - Google Maps'. So, my question is twofold, how can I get some code to click on the center of the map and scrape the title element?
Items in the 'place' field look like this.
https://www.google.com/maps/@42.33988,-71.10409,18z
https://www.google.com/maps/@39.73914,-75.54937,18z
https://www.google.com/maps/@44.4995,-88.05496,18z
https://www.google.com/maps/@44.50235,-88.06322,18z
https://www.google.com/maps/@40.82265,-73.40959,18z

