我的艾伯特·海恩图书馆

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第三方库


热门话题
无法在Netbeans 8.2 JDK8u231中创建java Maven项目(Web应用程序)   java如何以设定的时间间隔生成随机数?   java从socket和inputStream的慢速读取   spring SCORM:Java中基于Web的SCORM播放器   Java将函数传递给方法   java绑定通用服务及其实现和子类型   java如何在运行时从选择列表框中动态选择选项?爪哇硒   java Selenium WebDriver什么是“Selenium客户端和WebDriver语言绑定”   elasticsearch需要elasticsearch高级Java客户端更新ByQueryRequest API帮助   JAVA哈希表查找最大值   WSDL操作中的java soapAction属性为空   java访问封闭类或父类方法的一般方法   eclipse在java中运行带有SeleneTestCase的ANT。lang.NoClassDefFoundError   java Hazelcast不会在节点启动时填充ReplicatedMap   如何在Java中从excel中读取特定行?   html JAVA将本地时间(GMT+8)转换为UTC时间   java将自定义端点添加到Spring数据REST存储库中,并以大摇大摆的方式显示   java计算未来位置