Scraping Sephora and a Flask Querying Application

Posted on Feb 20, 2018

Photo by Eric Wüstenhagen

Introduction

For my scraping project, I decided to scrape product reviews from Sephora's website. Sephora is known as a one stop shop for a person's beauty needs, offering various brands of skincare, makeup, haircare, body and fragrance products at every price point.

The website holds more than 300 brands, at least 5000 products and thousands of reviews. The site was relatively easy to scrape and I was able to finish scraping ahead of schedule. With a lot of time on my hands, I took the opportunity to challenge myself by building a querying application using Flask.

How to Scrape Sephora

There are three page levels that you need to go through to reach the reviews area. First is the brands list page, which contains all the brands. Next is the brand page, where we can see all the products that the brand sells in the website. The product page is last. It includes specific information about the product, as well as its reviews. The reviews were not scraped from the site but were taken from an API which can be accessed by using the product ID.

 

Scraping the brand names and links is straightforward, with the names wrapped in a tag with class "u-hoverRed u-db u-p1" and the href link within the same location.

 

The product names, on the other hand, come as a dictionary search result which can be found on the bottom of the brand page's source code. I used Python's re package to get the product link, name, ID and average rating.

It was easier to scrape the total number of reviews from the product page, that's why I decided to go a level deeper, despite already having the information I needed to access the reviews API.

 

The product ID will then be used to construct the link where we can get the reviews and reviewer information. The link structure can be found in the web browser's Inspect Element in the Network area. After that go to the row named "reviews.json" under the header tab. The API will provide a dictionary which can be digested using the json package. The review text and reviewer's skintype, skintone, haircolor and eyecolor are gathered here. Running my scraping program on 17 brands resulted in the accumulation of more than 80,000 reviews.

Querying Application using Flask

I built a Flask Application that shows the top rated products given the brand or physical trait. I think it is useful to know which products are highly rated for a group of people with specific traits.

 

The application has three main areas, namely, the inputs, results and plot pages. Instead of detailing l how each page works here, I’d encourage you to try the application out to see for yourself!

About Author

Ansel Andro Santos

Ansel has a Master in Applied Mathematics from Ateneo de Manila University. He worked in the investments industry before deciding to become a data scientist. His interest in data science started while making the factor based investment strategy...
View all posts by Ansel Andro Santos >

Related Articles

Leave a Comment

Manoj August 10, 2018
Can you provide the github link, please?
Hafsa April 14, 2018
Hi, could you please guide me step by step to scrape the reviews? I am very confused about the methods and step to take. I saw your github and tried to make sense, but I couldn't follow. I need to present scraped data for the Sephora site by Monday morning ;(
Hafsa Laeeque April 14, 2018
Hi, could you please guide me step by step to scrape the reviews? I am very confused about the methods and step to take. I saw your github and tried to make sense, but I couldn't follow. I need to present scraped data for the Sephora site by Monday morning ;(

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI