GithubHelp home page GithubHelp logo

jtayped / mercapy Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 748 KB

🛍️ A Mercadona interface for Python to track product prices, amounts, and more.

Home Page: https://joeltaylor.business/

License: MIT License

Python 100.00%
api api-interface mercadona mercadona-scraper scraper

mercapy's Introduction


mercapy
🛍️ mercapy

A Mercadona interface for Python to track product prices, amounts, and more.

🔧 How to use it

First of all, install the package using:

pip install mercapy

By initializing the mercadona class, you can search products, recommendations, and new arrivals:

from mercapy import Mercadona

mercadona = Mercadona()

mercadona.search("galletas")
mercadona.get_new_arrivals()
mercadona.get_home_recommendations()

Each product has statistics such as:

from mercapy import Product

# Find product by ID
prod = Product("12345")

prod.name               # Beer
prod.unit_price         # 1.25€
prod.previos_price      # 1.95€
prod.is_discounted      # True
prod.bulk_price         # 7.5€
prod.is_pack            # True
prod.weight             # 0.5kg
prod.age_check          # True
prod.alcohol_by_volume  # 3.2%
prod.iva                # 21%

You can also interact with product photos:

from mercapy import Product

# Find product by ID
prod = Product("12345")
prod.images[0].save("product.png", width=1920, height=1080)

More docs coming soon...

🙋‍♂️ You may also like...

mercapy's People

Contributors

jtayped avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

esquitx

mercapy's Issues

Product class should also init with a dictionary

At the moment the Product class can be initialized with the product's ID. As the Mercadona API often responds with the full product info, instead of requesting it again when initialized, there should be the option of providing the product information directly.

Example:

from mercapy import Product

product_from_id = Product("12345")
# or
product_from_dict = Product({...})

Product class fetches information at __init__

When you init a product with an ID it fetches its information immediately, which adds time to the initialization of the class and takes a long time when initializing multiple products.
Before requesting information from the class there should be a check if the information exists or not, and should request it accordingly. This way, only the information which is strictly necessary will be request.

Warehouse postal codes wrong

When working on finding warehouse codes, I found out that only small warehouses are identified by their postal codes. But the ones in major cities have a code to them (e.g. Madrid has "mad1" and "mad2"). Courtesy of josantonius
's
repo here are some but not all codes:

2343 - Murcia
2749 - Lleida
3532 - Valencia
3947 - Tarragona
3951 - Girona
3996 - Barcelona
4068 - Barcelona
4069 - Barcelona
4097 - Barcelona
4230 - Navarra
4267 - Álava
4354 - Almería
4385 - Castellón
4416 - Girona
4472 - Barcelona
4558 - Castellón
4697 - Álava
alc1 - Alicante y Murcia
bcn1 - Barcelona
mad1 - Madrid
svq1 - Sevilla, Cádiz y Huelva
vlc1 - Valencia

It is interesting to note that some are not there such as "mad2" or "4115". This is probably due to the immense amount of warehouses that Mercadona has.

Product categories

As far as I've seen, products have 3 levels of categories, ranging from 0 to 2, from a general category to a specific one (e.g. Level 0: Cereal & biscuits -> Level 1: Biscuits -> Level 2: Breakfast cookies). You can find all available categories with the first endpoint below.
It is important to know that you can only search products by category using the second endpoint below with level 1 categories, for some reason you can't search more general or specific categories.
The idea for now is to have a category class that is defined with a level 1 ID.

  • All available categories: /api/categories/?lang=es&wh=4115
  • Specific category: /api/categories/181/?lang=es&wh=4115

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.