Coder Social home page Coder Social logo

Comments (2)

DakshinD avatar DakshinD commented on May 13, 2024 1

I ended up facing the same problem as you. Even when running in debug mode, I would have to manually click the new window for it to start working.

I added the following lines of code to the sort_by function in googlemaps.py, and while I now get reviews back, the Autofocus error is still outputted. This may be a temporary fix but you can give it a try for now til someone else can fix it properly.

       # move to sort button 
        sort_element = self.driver.find_element(By.XPATH, '//button[@data-value=\'Sort\']')
        actions = ActionChains(self.driver)
        actions.move_to_element(sort_element).perform()

The new sort_by function looks like this

    def sort_by(self, url, ind):

        self.driver.get(url)
        #self.__click_on_cookie_agreement()

        # move to sort button 
        sort_element = self.driver.find_element(By.XPATH, '//button[@data-value=\'Sort\']')
        actions = ActionChains(self.driver)
        actions.move_to_element(sort_element).perform()
        
        wait = WebDriverWait(self.driver, MAX_WAIT)

        # open dropdown menu
        clicked = False
        tries = 0
        while not clicked and tries < MAX_RETRY:
            try:
                menu_bt = wait.until(EC.element_to_be_clickable((By.XPATH, '//button[@data-value=\'Sort\']')))
                menu_bt.click()

                clicked = True
                time.sleep(3)
            except Exception as e:
                tries += 1
                self.logger.warn('Failed to click sorting button')

            # failed to open the dropdown
            if tries == MAX_RETRY:
                return -1

        #  element of the list specified according to ind
        recent_rating_bt = self.driver.find_elements_by_xpath('//div[@role=\'menuitemradio\']')[ind]
        recent_rating_bt.click()

        # wait to load review (ajax call)
        time.sleep(5)

        return 0

from googlemaps-scraper.

UNAVS avatar UNAVS commented on May 13, 2024

Does this supposed to open a Chrome test software window? Because there's no Chrome windows appeared once I ran the script. I got the same output as well, the reviews is 0. Already applied the solution above as well but still 0

from googlemaps-scraper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.