Created
March 4, 2025 17:16
-
-
Save iambibhas/bb199918d94177a57f6eb61645458a43 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
echo -n "How many days (max 2): " | |
read days | |
echo "Checking availability for ${days} day(s)..." | |
# Get the current year and month | |
year=$(date +%Y) | |
month=$(date +%m) | |
# Get the number of days in the current month | |
days_in_month=$(date -v+1m -v1d -v-1d +%d) | |
# Loop through each day of the month starting today | |
for day in $(seq -w $(date +%d) $days_in_month); do | |
check_in="${day}-${month}-${year}" | |
check_out=$(date -j -f "%d-%m-%Y" "${day}-${month}-${year}" +%s | xargs -I{} date -r {} -v+${days}d +%d-%m-%Y) | |
check_in_day=$(date -j -f "%d-%m-%Y" "${check_in}" +%A) | |
check_out_day=$(date -j -f "%d-%m-%Y" "${check_out}" +%A) | |
# echo "Checking availability for check-in date ${check_in} (${check_in_day}) and check-out date ${check_out} (${check_out_day})..." | |
response=$(curl -sS 'https://bandipurtigerreserve.org/check_availability_cottages.php' --compressed -X POST \ | |
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0' \ | |
-H 'Accept: */*' \ | |
-H 'Accept-Language: en-US,en;q=0.7,hi;q=0.3' \ | |
-H 'Accept-Encoding: gzip, deflate, br, zstd' \ | |
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ | |
-H 'X-Requested-With: XMLHttpRequest' \ | |
-H 'Origin: https://bandipurtigerreserve.org' \ | |
-H 'Connection: keep-alive' \ | |
-H 'Referer: https://bandipurtigerreserve.org/rooms_view.php' \ | |
-H 'Cookie: verifierlogin=8omi49q1pll412ei24e2mbj600' \ | |
--data-raw "check_in=${check_in}&check_out=${check_out}") | |
if echo "$response" | grep -q "Select</a>"; then | |
echo "Room available for check-in date ${check_in} (${check_in_day}) and check-out date ${check_out} (${check_out_day})." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment