GithubHelp home page GithubHelp logo

better_price's Introduction

Better Price

Better Price is a Django app that lets you search and compare e-book prices at any online bookstore. It is based on real-time web data scraping.

Tech Stack

AioHttp, Django, Celery, Redis, PostgreSQL, Channels, Django Rest Framework and Docker.

Requirements

  Python 3.10 or higher 
  Docker

Run

  1. Clone the project
  git clone https://github.com/MWasile/better_price
  1. Go to the project directory
  cd better_price
  1. Based on env/.evn-default create your own .env file

  2. Start the server

  docker compose up

Usage/Examples

Non-registered user:

  • Search for e-books.

Registered user:

  • Search for e-books.
  • Visit Dashboard.
  • Check your search history.
  • Set email alert for a price based on user input.

FAQ

How to add another bookstores?

Create your bookstores class in async_scraper.py

class NewBookstores:
    BOOKSTORE_URL = '' # bookstores url
    ALL_EBOOK_CONTAINER = '' # queryselector to main container with e-books on page.
    EBOOK_CONTAINER = '' # queryselector to single e-book container
    EBOOK_DETAILS = {
      #example
        'author': {'qs': 'a.smartAuthor', 'type': 'text'},
        'title': {'qs': '.ta-product-title', 'type': 'text'},
        'price': {'qs': '.price.ta-price-tile', 'type': 'decimal'},
        'jpg': {'qs': '.lazy', 'type': 'attribute', 'attr': 'lazy-img'},
        'url': {'qs': '.seoTitle', 'type': 'rel', 'attr': 'href', 'base': 'https://www.empik.com'}
    }

EBOOK_DETAILS represent data saved in database. Put your queryselector and choose type:

# support option:
'text' -> get text from queryselector.
'decimal' -> get price as decimal from queryselector.
'attribute' -> get value from tag attribute.
'rel' -> join realitve links with 'base'

Create your init only with future user input, next add your function for creating url.

    def __init__(self, user_input):
        self.user_input = user_input
        self.bookstores_url = self.get_url()

    def get_url(self):
      #example
        if len(self.user_input.split()) < 2:
            return ''.join([self.BOOKSTORE_URL, self.user_input])
        return ''.join([self.BOOKSTORE_URL, '%20'.join(self.user_input.split())])

add your class to settings.py

SCRAPER_BOOKSTORES = [
    # ...
    'NewBookstores',
    # ...
]

better_price's People

Contributors

mwasile avatar

Watchers

Paweł Konior avatar  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.