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

NoSuchElementException and find_element_by_xpath errors, can't run the script #3

Closed TheCastes closed 1 month ago

TheCastes commented 1 month ago

Here's the traceback

File "/home/cristianc/Scrivania/ads-scraper/app.py", line 96, in \<module> counter = counter() ^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/app.py", line 52, in counter result = driver.find_element_by_xpath('//body/div[2]/div[3]/div[8]/div[9]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[2]').find_element_by_class_name('fontBodySmall').text ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/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":"//body/div[2]/div[3]/div[8]/div[9]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[2]"} (Session info: chrome=127.0.6533.88)

MajideND commented 1 month ago

Can you uncomment this line: # options.add_argument("--headless") # show browser or not and see if the Google Maps reviews page is showing up. please use the default page that is used in the .env in your test.

TheCastes commented 1 month ago

Uncommented the line and resetted the URL to the default one, still getting this:

File "/home/cristianc/Scrivania/ads-scraper/app.py", line 96, in \<module> counter = counter() ^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/app.py", line 52, in counter result = driver.find_element_by_xpath('//body/div[2]/div[3]/div[8]/div[9]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[2]').find_element_by_class_name('fontBodySmall').text ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/cristianc/Scrivania/ads-scraper/lib/python3.12/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":"//body/div[2]/div[3]/div[8]/div[9]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[2]"} (Session info: chrome-headless-shell=127.0.6533.88)

TheCastes commented 1 month ago

If it helps you, i'm running Linux