-2

I have list of product names and i want to search a product name in following given URL and i need to fetch only price. for example i want to search "Tommee Tippee Disposable Breast Pads - 1 x 50 Pack" on this URL http://www.boots.ie/baby-child/babyfeeding/breastfeeding-pumps if i got successfull match then how can i get price i.e. €8.49 through scraping. this is one of the demo URL similarly i have list of URLs

Please help me to provide any example or Regular Expression to do this job

Adeel Nazir
  • 54
  • 10
  • 1
    StackOverflow is not a free code service. Show what you have tried and where in your code you got stuck. And direct your question to that specific problem. – Jorge Campos May 26 '17 at 12:28
  • 2
    Moreover, I'd suggest posting an extract of the data rather than a link to a website. You probably linked the website with good intentions, but it could be abused for advertising or malware propagation, which always makes me wary and less likely to answer your question. – Aaron May 26 '17 at 12:35

1 Answers1

1

A few sample code might help you kick off this project.

import re
from bs4 import BeautifulSoup

url = 'http://www.boots.ie/baby-child/babyfeeding/breastfeeding-pumps'
soup = BeautifulSoup(url, 'html.parser')
product_name_regex = 'Tommee Tippee Disposable Breast Pads - 1 x 50 Pack'
product_tag = soup.find('div', text=re.compile(product_name_regex))
price_tag = product_tag.find_next('div', { "class" : "product_price" })
price = price_tag.text

This short code is trying to parse the html page first, and then extract the information from that page through finding tags using text/class name.

A few links that might help you: BeautifulSoup Doc , How to find elements by class

Flames
  • 51
  • 6