MajideND / scraping-reviews-from-googlemaps

This is a simple script with python to scrap Google Maps reviews and ratings.
MIT License
38 stars 18 forks source link

Element not found. I give you an example URL #9

Open EnriqueGF opened 4 weeks ago

EnriqueGF commented 4 weeks ago

Trying this url:

URL = "https://www.google.com/maps/place/Clases+de+Boxeo+%26+Kickboxing+-+SPAHIRA+GYM/@37.8802424,-4.7953994,17.91z/data=!4m8!3m7!1s0xd6d216f369e8125:0xa518ba88ae914023!8m2!3d37.8803156!4d-4.7943974!9m1!1b1!16s%2Fg%2F11sfpvxvxg?entry=ttu"

It ends with entry ttu so it should work, it scrolls correctly but then I get:

`PS C:\Users\el_en\Desktop\scraping-reviews-from-googlemaps-main> python ./app.py starting...

DevTools listening on ws://127.0.0.1:65521/devtools/browser/7d5d5078-5116-4b42-84d5-8205e6839b9e scrolling... get data... Traceback (most recent call last): File "C:\Users\el_en\Desktop\scraping-reviews-from-googlemaps-main\app.py", line 122, in data = get_data(driver, counter[1]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\el_en\Desktop\scraping-reviews-from-googlemaps-main\app.py", line 27, in get_data childElementNameClass = childElement.find_element_by_xpath('.//div[1]/div[1]/div[2]/div[2]/div[1]/button[1]/div[1]').get_attribute('class') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\el_en\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\webelement.py", line 351, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\el_en\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\webelement.py", line 658, in find_element return self._execute(Command.FIND_CHILD_ELEMENT, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\el_en\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute return self._parent.execute(command, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\el_en\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\el_en\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":".//div[1]/div[1]/div[2]/div[2]/div[1]/button[1]/div[1]"} (Session info: chrome=127.0.6533.120)`

I also tried it headless.

Could you help me? Thank you ^^