For my first experience in Python, I’m using Selenium
and Beautifulsoup
to retrieve article titles from a website. However, I’m having trouble to take child from a div
, I just find the first span
but not the second…
I present you the div
:
<div class="d-flex justify-content-between font-size-14 font-weight-bold">
<span>Porte</span>
<span>epoxy blanc</span>
</div>
I tried that :
from bs4 import BeautifulSoup
items = soup.find_all("div", {"class": "col-12 col-sm-6 product--description--content--item"})
children = items.find_all("span")
print(len(children))
2
Answers
I hope you can modify my code whatever need you.
Also can try this
You could use
find_next_sibling()
to specify the element that you are looking for based on the one you still found:Example:
Output: