0

Here is the link: "https://btlaesthetics.com/en/find-a-physician"

I have searched a zip code '6292' in location search box by using selenium (as shown in code below). And it searches and shows results. Now it clicks on "Show details" of each clinic(section) 1 by 1, and it does so, but the main issue I'm facing is that, it scrapes data(telephone, email, website) of 1st section, each time it clicks on each section's detail, rather than scraping each section's own data. Here is the code:

from selenium import webdriver
from bs4 import BeautifulSoup
import time


options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(executable_path='D:\python\chromedriver\chromedriver.exe', options=options)
driver.get("https://btlaesthetics.com/en/find-a-physician")
driver.maximize_window()

element = driver.find_element_by_xpath("//input[@class='inp-text filter-address-input pac-target-input']")
element.send_keys("6292")
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
element.send_keys(u'\ue007')
time.sleep(3)

html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')

item_provider_near = soup.find_all('div', class_='item-provider')
for each in range(len(item_provider_near)):
    each = "(//a[@class='toggle-more'])[" + str(each+1) + "]"
    driver.find_element_by_xpath(each).click()
    time.sleep(3)
    phone = soup.find('span',class_='provider-phone').text
    email = soup.find('span',class_='provider-email').text
    website = soup.find('span',class_='provider-website').text
    if phone:
        print(phone)
    else:
        pass

    if email:
        print(email)
    else:
        pass

    if website:
        print(website)
    else:
        pass
driver.quit()

At the end, after scraping, it shows error: selenium.common.exceptions.elementnotinteractableexception message element not interactable

5
  • Please use this link: stackoverflow.com/questions/56194094/… Commented Apr 6, 2021 at 13:18
  • hey @sonulohani, now it hasn't show any error, but still shows the same results i.e. 1 section data Commented Apr 6, 2021 at 13:29
  • Can't you use try except block. If the elementnotinteractableexception exception is raised then pass it in except block. Commented Apr 6, 2021 at 13:33
  • No, it is not giving the error now, but showing wrong results, i.e 1st section data of each section Commented Apr 6, 2021 at 14:07
  • Oh I see... It is still showing data in html without even clicking on "show detail". Thanks Commented Apr 6, 2021 at 15:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.