Answer the question
In order to leave comments, you need to log in
How to get text from several identical tags at the same time?
Hello. I am writing a parser in python and I ran into this problem: the description text is divided into several paragraphs, each of which is in a separate . All of them lie in one, but besides them, there is one more directory with text that I don’t need. So you need to extract the tact from these 'r' so that it is one whole description. .find_all(p).get_text doesn't work, find(div).get_text doesn't work because it still unloads unnecessary text from another directory in it. So far, I've only pulled out the product name, but how do I pull out the description from all <p>'s? :
def get_content(text: str):
soup = bs4.BeautifulSoup(text, 'lxml')
items = soup.find_all('div', itemtype=" schema.org/Product ")
things = []
for item in items:
name = item.find('h1', itemprop="name").get_text()
except:
name = ''
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question