Giter Site home page Giter Site logo

appiepy's Introduction

โš ๏ธ AppiePy is no longer functional as of June 2021 โš ๏ธ

AppiePy depended on an undocumented internal Albert Heijn API to get product information. Albert Heijn removed this internal API in June 2021, so AppiePy has stopped working. Should another Albert Heijn API become available, anyone should be able to fork this repository and update it for the new API. AppiePy will not be updated. Thank you for using it in the past years!


AppiePy: A Python API for Albert Heijn

PyPI - Version PyPI - Downloads PyPI - License

AppiePy is a wrapper around Albert Heijn products you can find on their website https://ah.nl/. It allows you to retrieve information about these products and use it inside your application. Common uses are price/discount information, brand/category information, or nutritional information.

Installation

Installation can be done through pip:

pip install appiepy

Usage

from appiepy import Product
import json

# Full product url
product = Product('https://www.ah.nl/producten/product/wi193679/lay-s-paprika')

# Or just the path
product = Product('/producten/product/wi193679/lay-s-paprika')

print(json.dumps(product.__dict__, indent=4, sort_keys=True))

# {
#     "allergy": ["melk", "glutenbevattende granen", "tarwe"],
#     "brand": "Lay's",
#     "category": "Snoep, koek, chips en chocolade/Paprika chips",
#     "description": "Lay's Paprika",
#     "discount_period": "vanaf maandag",
#     "discount_type": "2 voor 2.00",
#     "features": [
#         { "identifier": "green_dot", "text": "Groene Punt" },
#         { "identifier": "recyclable_general_claim", "text": "Recyclebaar" }
#     ],
#     "id": "wi193679",
#     "image_url": "https://static.ah.nl/static/product/AHI_43545239373137323733_1_LowRes_JPG.JPG",
#     "ingredients": [
#         "aardappelen",
#         "plantaardige oli\u00ebn (zonnebloem, koolzaad, ma\u00efs, in wisselende hoeveelheden)",
#         "paprikasmaak [suiker, zout, paneermeel (van [b]TARWE[/b]), paprika, [b]MELKWEI[/b]-permeaat, uienpoeder, kaliumchloride, aroma's, knoflookpoeder, johannesbroodpitmeel, kleurstof (paprika-extract), rookaroma's, voedingszuren (citroenzuur en appelzuur)]"
#     ],
#     "is_available": true,
#     "is_discounted": false,
#     "nutrition": {
#         "Eiwitten": "6.4 g",
#         "Energie": "2244 kJ (538 kcal)",
#         "Koolhydraten": "54 g",
#         "Vet": "32 g",
#         "Voedingsvezel": "4.8 g",
#         "Waarvan suikers": "2.7 g",
#         "Waarvan verzadigd": "3.9 g",
#         "Zout": "1.2 g"
#     },
#     "price_current": 1.49,
#     "price_previous": null,
#     "summary": "De enige echte Lay's chips met paprikasmaak[list][*]Zonder kunstmatige kleurstoffen en conserveringsmiddelen\n[*]Zonder toegevoegde smaakversterkers\n[*]Bevat 7-8 porties\n[/list]",
#     "unit_size": "225 g",
#     "url": "/producten/product/wi193679/lay-s-paprika"
# }

Command Line Usage

python3 -m appiepy /producten/product/wi193679/lay-s-paprika

This logs a JSON representation of the product, similar to the logged output above.

appiepy's People

Contributors

hakankartal avatar jsoeterbroek avatar ricktav avatar rkalis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

appiepy's Issues

Nutrition parsing breaks on "<" symbol

This breaks:

from appiepy import Product

print(Product("/producten/product/wi420790/princes-tonijn-stukken-in-water").nutrition)

error: xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 211

I traced it back to an less than character in the nutrition table. (Koolhydraten < 0.1)

Cannot find products

Running the code provided in the example gives an ProductNotFoundException

from functions import Product
import json
product = Product('https://www.ah.nl/producten/product/wi193679/lay-s-paprika')
print(json.dumps(product.__dict__, indent=4, sort_keys=True))
<Response [404]>
Traceback (most recent call last):
  File "c:\Users\Amin\Documents\VSCode\Random Projects\SupermarktStuff\main.py", line 3, in <module>
    product = Product('https://www.ah.nl/producten/product/wi193679/lay-s-paprika')
  File "c:\Users\Amin\Documents\VSCode\Random Projects\SupermarktStuff\functions.py", line 52, in __init__
    raise ProductNotFoundException(url)
functions.ProductNotFoundException: Product with URL https://www.ah.nl/producten/product/wi193679/lay-s-paprika could not be found

Save nutritional information as a number

Currently, nutritional information is saved as a string, eg '3.0 g'. This makes it difficult to do any computations with this information. However, just parsing the number won't be enough, since you do need the unit information (is it in g or mg or kg?). It could be an idea to save the information in a tuple, eg (3.0, 'g').

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.