I have unordered list like this in HTML:
<ul>
<li class="label">Equipement</li>
<li>Aluminum tyres</li>
<li>4x4</li>
<li>3. stop lights</li>
<li>Bluetooth</li>
</ul>
Only first li
element in the ul
list contains title of the list, other elements contain list of features that needs to be extracted in plain text.
I know how to locate that first li
but I don't know how to select all other elements.
Consider that this ul
doesn't have class and its in the HTML document with a lot of other ul
elements.
I can locate that ul
through li
with:
(li.previousSibling).get_text()
but cannot extract all elements with get_text()
, I'm getting:
AttributeError: 'NavigableString' object has no attribute 'get_text'
Also I need to extract all li
except first one which holds title. I have several ul
on page like this and they are all variable in lenght (have more or less li
elements).
EDIT
My code so far. I'm finding elements with:
carBasics = soup.select('li.label')
for li in carBasics:
if li.contents[0]=="Equipement":
carAdditionalEquipement = (li.previousSibling).find_all('li')
AttributeError: 'NavigableString' object has no attribute 'get_text'