Michael Castellanos
Michael Castellanos

Reputation: 3

Python; Selenium find_elements error

Currently webscraping soundcloud, using the selenium library. I'm trying to view everything contained in the "sc-visuallyhidden" class but the .text() function only work on find_element and not find_elements. Any suggestions?

search = driver.find_elements_by_css_selector('span.sc-visuallyhidden')
print(search.text)

This returns an error.

Upvotes: 0

Views: 377

Answers (1)

Amit
Amit

Reputation: 20496

The find_elements method returns a list of elements. You can loop through each of them and print the text

elements = driver.find_elements_by_css_selector('span.sc-visuallyhidden')
for element in elements:
    print(element.text)

Upvotes: 1

Related Questions