I'm beginner in Python Webscriping using beautifulsoup. I was trying to scrape one real estate website using beautifulsoup but there is row with different information in each column. However each column's class name is same so When I trying to scrape information of each column, I got a same result becuase of same class name.
Link of the website I was trying to scrape.
Code From The HTML
<div class="lst-middle-section resale">
<div class="item-datapoint va-middle">
<div class="lst-sub-title stub text-ellipsis">Built Up Area</div>
<div class="lst-sub-value stub text-ellipsis">2294 sq.ft.</div>
</div>
<div class="item-datapoint va-middle">
<div class="lst-sub-title stub text-ellipsis">Avg. Price</div>
<div class="lst-sub-value stub text-ellipsis"><i class="icon-rupee"></i> 6.5k / sq.ft.</div>
</div>
<div class="item-datapoint va-middle">
<div class="lst-sub-title stub text-ellipsis">Possession Date</div>
<div class="lst-sub-value stub text-ellipsis">31st Dec, 2020</div>
</div>
Code I Tried!
for item in all:
try:
print(item.find('span', {'class': 'lst-price'}).getText())
print(item.find('div',{'class': 'lst-heading'}).getText())
print(item.find('div', {'class': 'item-datapoint va-middle'}).getText())
print('')
except AttributeError:
pass
If I use class 'item-datapoint va-middle' again then it shows sq.ft area not avg.price or Possession date.
Solution? TIA!