Giter VIP home page Giter VIP logo

sainsburysscraper's Introduction

Sainsburys Scraper

Usage instructions

Hello there :) This is my attempt at creating an extensible web scraper for the Sainsbury's groceries website.

dev vs client

To build the project, run:

./gradlew build

To run all tests, run:

./gradlew test

To run the project, run:

./gradlew run

Decision log

  • I decided to use a gradle wrapper in case you dont own the library or the correct version on your machine.
  • I assumed that anything that has less than 0.5g of kcal will be considered as 0 kcal (or non-existent)
  • I assumed that an unavailable description means you wont want to see it in the JSON

Results

Here are the results from the given link:

{
  "results": [
    {
      "title": "Sainsbury's Strawberries 400g",
      "kcal_per_100g": 140,
      "unit_price": 1.75,
      "description": "by Sainsbury's strawberries"
    },
    {
      "title": "Sainsbury's Blueberries 200g",
      "kcal_per_100g": 189,
      "unit_price": 1.75,
      "description": "by Sainsbury's blueberries"
    },
    {
      "title": "Sainsbury's Raspberries 225g",
      "kcal_per_100g": 133,
      "unit_price": 1.75,
      "description": "by Sainsbury's raspberries"
    },
    {
      "title": "Sainsbury's Blackberries, Sweet 150g",
      "kcal_per_100g": 134,
      "unit_price": 1.5,
      "description": "by Sainsbury's blackberries"
    },
    {
      "title": "Sainsbury's Blueberries 400g",
      "kcal_per_100g": 189,
      "unit_price": 3.25,
      "description": "by Sainsbury's blueberries"
    },
    {
      "title": "Sainsbury's Blueberries, SO Organic 150g",
      "unit_price": 2.0,
      "description": "So Organic blueberries"
    },
    {
      "title": "Sainsbury's Raspberries, Taste the Difference 150g",
      "kcal_per_100g": 133,
      "unit_price": 2.5,
      "description": "Ttd raspberries"
    },
    {
      "title": "Sainsbury's Cherries 400g",
      "unit_price": 2.5,
      "description": "by Sainsbury's Family Cherry Punnet"
    },
    {
      "title": "Sainsbury's Blackberries, Tangy 150g",
      "kcal_per_100g": 134,
      "unit_price": 1.5,
      "description": "by Sainsbury's blackberries"
    },
    {
      "title": "Sainsbury's Strawberries, Taste the Difference 300g",
      "kcal_per_100g": 140,
      "unit_price": 2.5,
      "description": "Ttd strawberries"
    },
    {
      "title": "Sainsbury's Cherry Punnet 200g",
      "unit_price": 1.5
    },
    {
      "title": "Sainsbury's Mixed Berries 300g",
      "unit_price": 3.5,
      "description": "by Sainsbury's mixed berries"
    },
    {
      "title": "Sainsbury's Mixed Berry Twin Pack 200g",
      "unit_price": 2.75
    },
    {
      "title": "Sainsbury's Redcurrants 150g",
      "kcal_per_100g": 300,
      "unit_price": 2.5,
      "description": "by Sainsbury's redcurrants"
    },
    {
      "title": "Sainsbury's Cherry Punnet, Taste the Difference 200g",
      "kcal_per_100g": 203,
      "unit_price": 2.5,
      "description": "Cherry Punnet"
    },
    {
      "title": "Sainsbury's Blackcurrants 150g",
      "unit_price": 1.75
    },
    {
      "title": "Sainsbury's British Cherry & Strawberry Pack 600g",
      "unit_price": 4.0
    }
  ],
  "total": 39.5
}

I've been a bit naughty and decided to find the real Sainsbury's website to test whether my code really works in 'production' (lol):

Here are the results for that:

{
  "results": [
    {
      "title": "Sainsbury's Strawberries 400g",
      "kcal_per_100g": 140,
      "unit_price": 2.0,
      "description": "by Sainsbury's strawberries"
    },
    {
      "title": "Sainsbury's Raspberries 150g",
      "kcal_per_100g": 133,
      "unit_price": 2.0,
      "description": "by Sainsbury's raspberries"
    },
    {
      "title": "Sainsbury's Blueberries 150g",
      "kcal_per_100g": 189,
      "unit_price": 2.0,
      "description": "by Sainsbury's blueberries"
    },
    {
      "title": "Sainsbury's Raspberries 225g",
      "kcal_per_100g": 133,
      "unit_price": 2.85,
      "description": "by Sainsbury's raspberries"
    },
    {
      "title": "Sainsbury's Strawberries 227g",
      "kcal_per_100g": 140,
      "unit_price": 1.75,
      "description": "by Sainsbury's strawberries"
    },
    {
      "title": "Sainsbury's Blackberries, Sweet 150g",
      "kcal_per_100g": 134,
      "unit_price": 2.0,
      "description": "by Sainsbury's blackberries"
    },
    {
      "title": "Sainsbury's Blueberries, SO Organic 150g",
      "unit_price": 2.7,
      "description": "So Organic blueberries"
    },
    {
      "title": "Sainsbury's Strawberries, Greengrocer 250g",
      "kcal_per_100g": 140,
      "unit_price": 1.1,
      "description": "Strawberries"
    },
    {
      "title": "Sainsbury's Raspberries, Taste the Difference 150g",
      "kcal_per_100g": 133,
      "unit_price": 2.75,
      "description": "Ttd raspberries"
    },
    {
      "title": "Sainsbury's Blackberries, Tangy 150g",
      "kcal_per_100g": 134,
      "unit_price": 2.0,
      "description": "by Sainsbury's blackberries"
    },
    {
      "title": "Sainsbury's Strawberries, Taste the Difference 300g",
      "kcal_per_100g": 140,
      "unit_price": 3.0,
      "description": "Ttd strawberries"
    },
    {
      "title": "Sainsbury's Strawberries, SO Organic 300g",
      "kcal_per_100g": 140,
      "unit_price": 2.5,
      "description": "SO Organic strawberries"
    },
    {
      "title": "Sainsbury's Raspberries, SO Organic 125g",
      "kcal_per_100g": 133,
      "unit_price": 2.5,
      "description": "SO Organic raspberries"
    },
    {
      "title": "Sainsbury's Mixed Berries 300g",
      "unit_price": 3.5,
      "description": "by Sainsbury's mixed berries"
    },
    {
      "title": "Sainsbury's Mixed Berry Twin Pack 200g",
      "unit_price": 3.0
    },
    {
      "title": "Sainsbury's Blackberries, Tangy 225g",
      "kcal_per_100g": 134,
      "unit_price": 2.85,
      "description": "by Sainsbury's blackberries"
    },
    {
      "title": "Sainsbury's Extra Large Blueberries 200g",
      "unit_price": 2.0
    }
  ],
  "total": 40.5
}

sainsburysscraper's People

Contributors

zkhan96 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.