Skip to content

Instantly share code, notes, and snippets.

@mrknmc
Last active June 1, 2023 02:30
Show Gist options
  • Save mrknmc/46b587dc612d937daaa9 to your computer and use it in GitHub Desktop.
Save mrknmc/46b587dc612d937daaa9 to your computer and use it in GitHub Desktop.
ASDA Groceries parsing
#!/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
@bi-ai-programmer
Copy link

Many thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment