Danzigerrr / Google-Maps-Scraper

Collect data about places of specified type from the specified area from the Google Maps.
MIT License
9 stars 3 forks source link

Selenium timeout exception #1

Open jdtorres96 opened 1 year ago

jdtorres96 commented 1 year ago

Hi, I am getting the following error when trying to replicate the scraper. Do you knwo how can I fix it? Thanks!

(base) jdtorres@SIE-C02G50GLML86 Google-Maps-Scraper-master % /Users/jdtorres/opt/anaconda3/bin/python /Users/jdtorres/Downloads/Google-Map s-Scraper-master/MainScraper.py /Users/jdtorres/Downloads/Google-Maps-Scraper-master/MainScraper.py:21: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome(ChromeDriverManager().install()) ['bar', 'cinema', 'office'] total number of points to check:175 Traceback (most recent call last): File "/Users/jdtorres/Downloads/Google-Maps-Scraper-master/MainScraper.py", line 183, in new_places = searchForPlace(url, typeOfPlace) File "/Users/jdtorres/Downloads/Google-Maps-Scraper-master/MainScraper.py", line 72, in searchForPlace clickAcceptAllButton() File "/Users/jdtorres/Downloads/Google-Maps-Scraper-master/MainScraper.py", line 101, in clickAcceptAllButton button = wait.until(EC.visibility_of_element_located((By.XPATH, button_path))) File "/Users/jdtorres/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 95, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Stacktrace: 0 chromedriver 0x000000010d740598 chromedriver + 4973976 1 chromedriver 0x000000010d737913 chromedriver + 4938003 2 chromedriver 0x000000010d2f4cd6 chromedriver + 470230 3 chromedriver 0x000000010d3382ff chromedriver + 746239 4 chromedriver 0x000000010d338591 chromedriver + 746897 5 chromedriver 0x000000010d37a384 chromedriver + 1016708 6 chromedriver 0x000000010d35c9ed chromedriver + 895469 7 chromedriver 0x000000010d377856 chromedriver + 1005654 8 chromedriver 0x000000010d35c793 chromedriver + 894867 9 chromedriver 0x000000010d32a21f chromedriver + 688671 10 chromedriver 0x000000010d32b56e chromedriver + 693614 11 chromedriver 0x000000010d6fabb7 chromedriver + 4688823 12 chromedriver 0x000000010d6ffa51 chromedriver + 4708945 13 chromedriver 0x000000010d70640f chromedriver + 4736015 14 chromedriver 0x000000010d70091a chromedriver + 4712730 15 chromedriver 0x000000010d6d387c chromedriver + 4528252 16 chromedriver 0x000000010d71ff28 chromedriver + 4841256 17 chromedriver 0x000000010d7200a7 chromedriver + 4841639 18 chromedriver 0x000000010d73128f chromedriver + 4911759 19 libsystem_pthread.dylib 0x00007ff816b111d3 _pthread_start + 125 20 libsystem_pthread.dylib 0x00007ff816b0cbd3 thread_start + 15

Danzigerrr commented 1 year ago

Hi @jdtorres96 I have checked your issue and updated the code to solve it. I changed the way the scrolling of the menu is performed. Here is the new code:

def scrollDownLeftMenuOnGoogleMaps(counter, waitingTime):
    """
    This function is responsible for scrolling down the menu visible at the left.
    It is used while searching for places at Google Maps. It allows seeing more places relevant for the search value.

    :param counter: number of scrolls down
    :param waitingTime: waiting time until next scroll (new results are loaded)
    """
    menu_xpath = '/html/body/div[3]/div[9]/div[9]/div/div/div[1]/div[2]/div/div[1]/div/div/div[2]/div[1]/div[3]/div'
    if check_exists_by_xpath(menu_xpath):
        for i in range(counter):
            # wait until element is located
            wait = WebDriverWait(driver, waitingTime)
            menu_left = wait.until(EC.visibility_of_element_located((By.XPATH, menu_xpath)))

            # perform scrolling down
            scroll_origin = ScrollOrigin.from_element(menu_left)
            ActionChains(driver).scroll_from_origin(scroll_origin, 0, 500).perform()

Please let me know if everything works correctly so I can close this issue. Happy coding!

jdtorres96 commented 1 year ago

Hi @KrzysztofNazar01, thanks so much for your help! I've tried the new code but am still getting the same problem. I wonder if it has to do with some google chrome configuration. Also, I am running this in a Mac