lyyka / google-maps-businesses-scraper

Built with Python running Selenium, this app allows you to scrape places info from the google maps search results
MIT License
62 stars 25 forks source link

no such element: Unable to locate element: {"method":"css selector","selector":"[name="q"]"} #3

Open rgaufman opened 3 years ago

rgaufman commented 3 years ago

When I launch the map, it opens a browser window and I see this:

$ python3 script.py --query="Hairdressers" --places="WC2N"
Moving on to WC2N
Traceback (most recent call last):
  File "/Users/hackeron/google-maps-businesses-scraper/script.py", line 6, in <module>
    scrape(args)
  File "/Users/hackeron/google-maps-businesses-scraper/modules/scraper.py", line 67, in scrape
    q_input = driver.find_element_by_name("q")
  File "/opt/homebrew/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 496, in find_element_by_name
    return self.find_element(by=By.NAME, value=name)
  File "/opt/homebrew/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "/opt/homebrew/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/opt/homebrew/lib/python3.9/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":"css selector","selector":"[name="q"]"}
  (Session info: chrome=89.0.4389.128)

Screenshot 2021-04-18 at 17 27 47

Any ideas?

nyolcaserno commented 3 years ago

Did you find the solution? I have the same problem. Thanks! :)

nyolcaserno commented 3 years ago

Looking for these lines in screper.py file:

for place in SETTINGS["PLACES"]:

Go to the index page

    driver.get(SETTINGS["MAPS_INDEX"])

Add to this: time.sleep (4) elem = driver.find_element_by_css_selector("#yDmH0d > c-wiz > div > div > div > div.NIoIEf > div.G4njw > div.AIC7ge > form > div.lssxud > div > button") elem.click()
time.sleep (5)

Jackahack commented 1 year ago

that is also out of date and i am having trouble to get the correct button selector. when i try to put in the button selector it gives the error not interactable

sakshamahluwalia commented 1 year ago

This works as of Feb 2, 2022:

q_input = driver.find_element(By.NAME, "q")
q_input.send_keys(query, Keys.ENTER)