我的艾伯特·海恩图书馆

mijnah的Python项目详细描述


米伊纳

与mijn Albert Heijn V2 API交互

安装

pip install mijnah

使用

推车

AH使用recaptcha令牌进行身份验证,因此传递ah_token或{}(在验证后的cookie中找到)更容易。在

  • 身份验证:

    ^{pr2}$ 在
  • 购物车:

    ah.list_cart()
  • 将商品添加到购物车:

    ah.add_to_cart(product_id=1234,amount=2)

    id可以在产品url中找到。例如,https://www.ah.nl/producten/product/wi471282/chatelain-notre-dame-medoc中的id是471282。在

  • 更新购物车:

    ah.update_cart(product_id=1234,amount=0)
  • 空车:

    ah.empty_cart()

产品

  • 初始化:
    importmijnahp=mijnah.Product(product_id=1234)
  • 对象属性:
    p.idp.namep.categoryp.descriptionp.brandp.price

示例

获取购物车总数

importmijnahimportjsonah=mijnah.Cart(ah_token_presumed='ah_token')ah.empty_cart()# add some itemsah.add_to_cart(product_id=168153,amount=2)ah.add_to_cart(product_id=224710,amount=1)ah.add_to_cart(product_id=129138,amount=3)ah.add_to_cart(product_id=198412,amount=2)cart=ah.list_cart()# Generate invoiceprint(json.dumps([{'product':item['product'].name,'quantity':item['quantity'],'price':item['product'].price,'total':item['quantity']*item['product'].price}foritemincart],indent=2))# Get total itemsprint('total items:',sum(item['quantity']foritemincart))# Get total itemsprint('total price:',sum(item['quantity']*item['product'].priceforitemincart))
[{"product":"AH IJsbergsla voordeel","quantity":2,"price":1.79,"total":3.58},{"product":"AH Babyspinazie","quantity":1,"price":1.59,"total":1.59},{"product":"AH Frambozen","quantity":3,"price":2.39,"total":7.17},{"product":"Valle del sole Popcorn ma\u00efs","quantity":2,"price":1.53,"total":3.06}]totalitems:8totalprice:15.4

变更日志

1.2.0款

  • 添加了使用ah_tokenah_token_presumed,或两者都使用的功能。在
  • 添加的测试

1.1.0款

  • 初始版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Intellij新项目JDK不可用   JAVA静态块执行了多少次?   java通过JCheckBox更改文本字段输入的字体颜色   java在星期几文本字段中输入值   java RichFaces 4.2日历。如何通过JavaScript设置日历的输入字段?   java在javafx中注册鼠标处理程序,但处理程序不是内联的   java将jchararray分配给常量unsigned char   在安卓4.4中注意到java奇怪的圆形浮动动作按钮吗?   java中用于解决8个难题的合适的树类是什么   为什么Java在我的Linux服务器上使用了如此多的内存?   java从多个推荐列表中提取顶级推荐   “426写入网络流失败。”尝试使用Java的URL类连接到FTP站点时收到   java如何在没有Gradle的情况下使用IntelliJ打开项目?   java如何在线程完成后使For循环继续?   java使用定制jackson ObjectMapper定制Spring引导序列化过程   java NativeActivity不会显示在屏幕上   如何使用Java中的EditorConfig在IntelliJ IDEA中关闭rightparen自己的行?   java从字符串中删除字母数字单词   Intellij IDEA 13.1中的maven Java编译错误