How to extracted specific information such as cost and name of a product?

But I facing problem to extract data from bs4 tag and i am not able to extract only the product name and costi am not able to extract exact exact 159995(without rupee sign and commas)

same goes with the name of the product not able to extract name of the productenter image description here

I tried using indexing but that failed since it is a tag I have also used .getText() and .get_text() and tried converting into str and append into list that also failed and not able to get exact info required.

I am not able to extract exact 159995(without rupee sign and commas) in first image and product name in second image

>Solution :

Based on your example it should be the following, cause there is only one tag in your ResultSet:


Else you have to iterate your ResultSet:

for e in'.BNuCI'):

Based on your comment:

It is the same way for the cost and you could extract with regex e.g. the numbers only:

import re
cost = ''.join(re.findall(r'\d+', soup.select_one('.YOURCLASSVALUES').get_text(strip=True)))

Leave a Reply