Last active
June 1, 2023 02:30
-
-
Save mrknmc/46b587dc612d937daaa9 to your computer and use it in GitHub Desktop.
ASDA Groceries parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### This only works assuming that you have all the necessary cookies in ./cookies.txt. | |
### I use this plugin: https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg | |
### Execute as follows: ./shopping.sh ./cookies.txt output.csv | |
# get last order id | |
order_id=$(curl -s -b $1 'https://groceries.asda.com/api/order/view?showmultisave=true&showrefund=true&pagenum=1&pagesize=25&requestorigin=gi' | jq -r '.orders | .[0] | .orderId') | |
# get url for last order | |
url="https://groceries.asda.com/api/order/view?showmultisave=true&showrefund=true&orderid=$order_id&responsegroup=extended&pagesize=nolimit&pagenum=1&requestorigin=gi&_=1423573864762" | |
# produce csv of products from last order | |
curl -s -b $1 ${url} --compressed | jq -r '.orders | .[0] | .item | sort_by(.promoDetail) | .[] | [.desc, .qty, .cost, .price, .promoDetail] | @csv' > $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks for this.