Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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:

soup.select_one('.BNuCI').get_text(strip=True)

Else you have to iterate your ResultSet:

for e in soup.select('.BNuCI'):
    print(e.get_text(strip=True))

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)))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading