I'm trying to pull out data using BeautifulSoup library in python. I used zip and soup to extract.
My html data looks like this :
<li>
<ul class="features">
<li>Year: <strong>2016</strong></li>
<li>Kilometers: <strong>81,000</strong></li>
</ul>
<ul class="features">
<li>Doors: <strong>2 door</strong></li>
<li>Color: <strong>White</strong></li>
</ul>
<ul class="features">
</ul>
</li>
Here i want to get year,kilometers,doors,color in seperate variables. But when i run my code it getting together.
My code :
for title, price, date, features in zip(soup.select('.listing-item .title'),
soup.select('.listing-item .price'),
soup.select('.listing-item .date'),
soup.select('.listing-item .features')):
title = title.get_text().strip()
price = price.get_text().strip()
date = date.get_text().strip()
features = features.get_text().strip()
print(features)
Output :
Year: 2016
Kilometers: 81,000
Doors: 2 door
Color: White
How i can store the year,kilometers,doors,colors in seperate variables ?