Home > other >  Get city name from a list of raw address with selenium
Get city name from a list of raw address with selenium

Time:08-15

I have a list of address list_x = ['A', 'B', 'C', 'D'] and i want to send these value into google map search one by one.

My code here:

from selenium import webdriver
import time
from time import sleep
path = r"C:/Users/admin/chromium-browser/chromedriver.exe"
options = webdriver.ChromeOptions()
options.binary_location = r"C:\Users\sonpn.vbi\AppData\Local\Google\Chrome\Application\chrome.exe"
driver = webdriver.Chrome(path, chrome_options=options)
driver.get("https://www.google.co.in/maps/@10.8091781,78.2885026,7z")
sleep(2)
for index, item in enumerate(list_x, start=0):  
    Place = driver.find_element("class name", "tactile-searchbox-input").send_keys(item)
    Submit = driver.find_element("xpath", "//*[@id='searchbox-searchbutton']").click()
    result = driver.find_elements("xpath", '//*[@id="QA0Szd"]/div/div/div[1]/div[2]/div/div[1]/div/div/div[2]/div[1]/div[1]')
    convert1 = [el.text for el in result]
    convert.extend(convert1)
    time.sleep(3)
    close = driver.find_element('xpath', '//*[@id="sb_cb50"]').click()

and the error is

WebDriverException: Message: chrome not reachable (Session info: chrome=97.0.4692.71)

Please help me with this error. Thank you

CodePudding user response:

This error message...

WebDriverException: Message: chrome not reachable (Session info: chrome=97.0.4692.71)

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. session.

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Possibly you are using the latest chrome=104.0
  • But you are using chromedriver=97.0

So there is a clear mismatch between chromedriver=97.0 and the chrome=104.0


Solution

Ensure that:

  • Related