Answer the question
In order to leave comments, you need to log in
Python - How to select the right row?
When parsing a site, there is such a layout
<span class="packaging-info">
Qty: 1+
<span class="packing-price">$0.395</span>
</span>
.find('span', class_='packaging-info').text.strip()
Answer the question
In order to leave comments, you need to log in
>>> body = """
... <span class="packaging-info">
... Qty: 1+
... <span class="packing-price">$0.395</span>
... </span>
... """
>>> soup = BeautifulSoup(body, 'lxml')
>>> elem = soup.find('span', class_='packaging-info')
>>> elem.next_element.strip()
'Qty: 1+'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question