[Python] How to scroll down google maps using selenium python

Discussão em 'Python' iniciado por Stack, Junho 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to scroll down the google maps page using selenium but unable to do so. I have tried all the things written here: Scroll down google maps webpage using selenium python

    Here is my code:

    def scroll(self):
    SCROLL_PAUSE_TIME = 5

    # Get scroll height
    last_height = self.execute_script("return document.body.scrollHeight")

    number = 0

    while True:
    number = number+1

    # Scroll down to bottom

    ele = self.find_element_by_css_selector('div[jstcache="211"]')
    print(ele)
    self.execute_script('arguments[0].scrollBy(0, 500)', ele)

    # Wait to load page

    time.sleep(SCROLL_PAUSE_TIME)

    # Calculate new scroll height and compare with last scroll height
    print(f'last height: {last_height}')

    ele = self.find_element_by_css_selector('div[jstcache="211"]')

    new_height = self.execute_script("return arguments[0].scrollHeight", ele)

    print(f'new height: {new_height}')

    if number == 5:
    break

    if new_height == last_height:
    break

    print('cont')
    last_height = new_height


    but cannot figure out how to scroll down.

    Kindly help!!

    Continue reading...

Compartilhe esta Página