Susan
Susan

Reputation: 41

BeautifulSoup method to retrieve the text from an element

What is the BeautifulSoup method for retrieving text from an element. I haveprices = soup.find_all('p', class_='price_color') and want to retrieve the text from prices. I tried p = prices.get_text() but got an error stating: 'ResultSet' object has no attribute 'text'

Upvotes: 0

Views: 44

Answers (1)

Daveedo
Daveedo

Reputation: 172

find_all returns a ResultSet object and you can iterate that object using a for loop.

You can try something such as:

for values in soup.find_all('p', class_='price_color'): print values.text

Upvotes: 2

Related Questions