Skip to content

Instantly share code, notes, and snippets.

@erickhun
Created June 18, 2021 07:51
Show Gist options
  • Save erickhun/d80f8fe81926a5e70c9452cb8e501b4d to your computer and use it in GitHub Desktop.
Save erickhun/d80f8fe81926a5e70c9452cb8e501b4d to your computer and use it in GitHub Desktop.
Get notified when your Taiwan Gold Card Application status changes
#!/bin/bash
LAST_DUMP_FILE=./last_dump
DATE=`date +%Y-%m-%d_%H-%M`
FILENAME="dump_"${DATE}
EMAIL='xxx@gmail.com'
function check_status () {
## Each curl is specific to a given user. You can get the proper curl via the Chrome dev tool in network tabs -> copy -> copy curl
curl 'https://coa.immigration.gov.tw/coa-frontend/todo/tab-1?_=1623997345783' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' -H 'Accept: */*' -H 'DNT: 1' -H 'X-Requested-With: XMLHttpRequest' -H 'sec-ch-ua-mobile: ?0' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Dest: empty' -H 'Referer: https://coa.immigration.gov.tw/coa-frontend/home' -H 'Accept-Language: en-US,en;q=0.9,fr;q=0.8,zh-CN;q=0.7,zh;q=0.6,ru;q=0.5,ja;q=0.4,zh-TW;q=0.3' -H 'Cookie: JSESSIONID=XXXXXXXXX' --compressed > $FILENAME
}
check_status
if test -f "$LAST_DUMP_FILE"; then
echo "Comparing..."
if diff $FILENAME $LAST_DUMP_FILE &> /dev/null ; then
echo "Files are the same"
else
echo "Files changed:"
OUTPUT=$(diff $FILENAME $LAST_DUMP_FILE 2>&1)
echo $OUTPUT
echo "Gold Card Application changed: $OUTPUT" | mail -s "Gold Card Application status just changed" ${EMAIL}
fi
cp $FILENAME $LAST_DUMP_FILE
else
echo "$LAST_DUMP_FILE NOT exists. Creating the file. We don't need to diff"
cp $FILENAME $LAST_DUMP_FILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment