0

I am trying to web scrape the site but I am constantly getting webdriver has no attribute find elements by class name.

from selenium import WebDriver
url="https://www.justdial.com/Pune/Stationery-Shops/nct-10453443"
driver = webdriver.Chrome()
driver.get(url)
data= driver.find_elements_by_class_name('resultbox_textbox')
print(data)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_3244\3988657068.py in <module>
      3 driver = webdriver.Chrome()
      4 driver.get(url)
----> 5 data= driver.find_elements_by_class_name('resultbox_textbox')
      6 data

AttributeError: 'WebDriver' object has no attribute 'find_elements_by_class_name'
'''
1

1 Answer 1

1

Downgrade the selenium version to make this syntax work (you're using the silenium version 3 syntax):

pip3 install 'selenium<4.0.0'

Or use the syntax of version 4:

from selenium.webdriver.common.by import By
data = driver.find_element(By.CLASS_NAME,'resultbox_textbox')
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, It got resolved.

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.