Home > Net >  scroll google map webpage sidebar using selenium and python
scroll google map webpage sidebar using selenium and python

Time:11-10

I am trying to collect data on a google map webpage, this is the link. check image

what is the solution for this?

EDIT:This is what I'm trying to get. enter image description here

CodePudding user response:

At least on my side I see no need to scroll.
The following code worked:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 20)

url = "https://www.google.com/maps/place/Amsterdamsche Athleten Club Hercules/@52.36937,4.8049968,16z/data=!4m5!3m4!1s0x47c5e3c9cbb3d913:0xef85f93ef996cc06!8m2!3d52.3692292!4d4.8056684"

driver.get(url)
name = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "[data-item-id='authority']"))).text
print(name)

Output:

aachercules.nl

The same could be done with XPath instead of CSS Selectors.
This is the XPath I used:

name = wait.until(EC.visibility_of_element_located((By.XPATH, "//a[@data-item-id='authority']"))).text
  • Related