Skip to content

Instantly share code, notes, and snippets.

@sjparkinson
Last active April 30, 2020 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjparkinson/8fcdb8e4dd99ba05d330b3cb91e0875d to your computer and use it in GitHub Desktop.
Save sjparkinson/8fcdb8e4dd99ba05d330b3cb91e0875d to your computer and use it in GitHub Desktop.
Usage: ./ocado.sh $OCADO_SESSION_ID
#!/bin/bash
echo 'Starting Ocado slot checker...'
COUNT=0
CURRENT_STATUS_CODE=404
echo
ocado_slot_status() {
curl -s -o /dev/null -w "%{http_code}" \
--request GET \
--url 'https://www.ocado.com/webshop/getNextAvailableSlot.do?ajax=true' \
--header 'referer: https://www.ocado.com/webshop/startWebshop.do' \
--cookie "W3SESSIONID=$1.OCADO120; OCADOSESSIONID=$1;"
}
while [[ "$CURRENT_STATUS_CODE" -eq 404 ]]
do
CURRENT_STATUS_CODE=$(ocado_slot_status "$1")
((COUNT+=1))
echo -e "\r\033[1A\033[0KAvailable slots have been checked $COUNT times"
sleep 60;
done
if [[ "$CURRENT_STATUS_CODE" -eq 302 ]]
then
echo 'The session has expired, please restart the script with a valid Ocado session ID'
open 'https://www.ocado.com/'
exit 1;
fi
echo 'Found potential slot, opening the delivery page...'
open 'https://www.ocado.com/webshop/getAddressesForDelivery.do?checkout=no'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment