Skip to content

Instantly share code, notes, and snippets.

@sjparkinson

sjparkinson/ocado.sh

Last active Apr 30, 2020
Embed
What would you like to do?
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