Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale Element Reference Error #36

Open
Maunil2k opened this issue Feb 14, 2023 · 5 comments
Open

Stale Element Reference Error #36

Maunil2k opened this issue Feb 14, 2023 · 5 comments
Assignees

Comments

@Maunil2k
Copy link

Hi @gaspa93,
I was trying to use the following URL: https://www.google.com/maps/place/Ellora+Caves/@20.025817,75.1779975,17z/data=!4m7!3m6!1s0x3bdb93bd138ae4bd:0x574c6482cf0b89cf!8m2!3d20.025817!4d75.1779975!9m1!1b1
for scraping N=1000 reviews and sort by = most relevant when I got this error: selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
Full error:

[Review 0]
Traceback (most recent call last):
File "scraper.py", line 63, in
reviews = scraper.get_reviews(n)
File "/home/maunil/Desktop/googlemaps-scraper/googlemaps.py", line 172, in get_reviews
self.__expand_reviews()
File "/home/maunil/Desktop/googlemaps-scraper/googlemaps.py", line 298, in __expand_reviews
l.click()
File "/home/maunil/Desktop/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/maunil/Desktop/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "/home/maunil/Desktop/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "/home/maunil/Desktop/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: headless chrome=103.0.5060.114)

@gaspa93
Copy link
Owner

gaspa93 commented Mar 24, 2023

Hi @Maunil2k,
I tried the link provided and it seems to work. What is the exact command you are trying to execute?

@Maunil2k
Copy link
Author

Hi @gaspa93 ,
This is command that I'm using python scraper.py --N 1000 --sort_by most_relevant

@gaspa93
Copy link
Owner

gaspa93 commented Mar 25, 2023

I tried with lower value of N and it works correctly: do you get the error immediately or after some time?

@Maunil2k
Copy link
Author

I get the error almost 2 secs after the crawler selects most relevant from the sort by menu.

@gaspa93
Copy link
Owner

gaspa93 commented Apr 3, 2023

Very strange, it works fine for me: did you have all requirements installed and updated?

@gaspa93 gaspa93 self-assigned this Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants