I have a pretty interesting question. I wanted to automate reserving timeslots for my university's gym as you need to book 3 days in advance if you want a chance at a workout. I am using a framework called selenium to do this in python and I've gotten to the point where I wrote the logic to reserve slots, but I noticed a glaring problem, the only times that open are mostly inconvenient. Furthermore, I compared my session with my housemate's session and he has different timeslots shown than mine.
I'm looking to somehow 'hack' my way to get a time that fits my schedule to exercise and as you can imagine I'm very new to all this. I'm hoping someone can point me in the right direction.
Here's what the page looks like
I noticed that the "BOOK NOW" button onclick attribute had a javascript function called Reserve binded to it.
<button class="btn btn-primary" type="button" onclick="Reserve('c062459d-a12c-493b-86f7-dfb2b2e82de4', '4d939fdc-b4f8-4ee6-bda0-ff5e1f8a479e', '36f4c64a-ee97-43d4-b20d-ec03274bc7fd', 1)">Book Now</button>
and I have no idea how the first three strings are generated. Those three strings dynamically change as the user clicks one of the four following respective buttons for the dates.
<button type="button" class="btn single-date-select-button single-date-select-one-click btn-primary" data-button-index="1" data-year="2020" data-month="11" data-day="7" data-date-text="Nov 7, 2020">
</button>
<button type="button" class="btn single-date-select-button single-date-select-one-click btn-default" data-button-index="2" data-year="2020" data-month="11" data-day="8" data-date-text="Nov 8, 2020">
</button>
<button type="button" class="btn single-date-select-button single-date-select-one-click btn-default" data-button-index="3" data-year="2020" data-month="11" data-day="9" data-date-text="Nov 9, 2020">
</button>
<button type="button" class="btn single-date-select-button single-date-select-one-click btn-default" data-button-index="4" data-year="2020" data-month="11" data-day="10" data-date-text="Nov 10, 2020">
</button>
Since there are only three slots shown to me (all with 0 spots available) here are examples of what they could look like:
Reserve('8cd64464-5131-48d5-bb48-5e1813199736', '6cc73871-2718-4daf-9665-353ae69c1874', 'a34da0c4-fdd4-4ef4-9217-cd2539c4d41f', 1)
Reserve('c062459d-a12c-493b-86f7-dfb2b2e82de4', '4d939fdc-b4f8-4ee6-bda0-ff5e1f8a479e', '36f4c64a-ee97-43d4-b20d-ec03274bc7fd', 1)
Reserve('d51878d9-d020-41fe-a335-5a1c27e24a7b', '5fe72851-5c82-4ddc-a742-1cc0815eb1a4', '2c2f1463-8240-4510-9a68-51fffdaad90f', 1)
when I run:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get(booking_url)
# Login stuff
driver.execute_script("Reserve('d51878d9-d020-41fe-a335-5a1c27e24a7b', '5fe72851-5c82-4ddc-a742-1cc0815eb1a4', '2c2f1463-8240-4510-9a68-51fffdaad90f', 1)")
It actually does perform everything right and even runs the js code prompting me with the booking successful message as shown in 1 as well as error messages for when I reserve a slot with 0 open.
How do I go about figuring out how those strings are generated? Could they be user specific like when I log in with my kerebos credentials, or are they a browser cookie or even from the database serving the page?
I found this too in the Scripts/ for this web page:
function Reserve(appointmentId, timeSlotId, timeSlotInstanceId, slotNumber) {
$('.booking-slot-item[data-slot-number=' + slotNumber + '] .booking-slot-action-item button').attr('disabled', 'disabled').html('Booking...');
let postData = {
bookingId: BookingId,
facilityId: SelectedFacilityId,
appointmentId: appointmentId,
timeSlotId: timeSlotId,
timeSlotInstanceId: timeSlotInstanceId,
year: SelectedYear,
month: SelectedMonth,
day: SelectedDay
};
$.post('/booking/reserve', postData).done(function (response) {
if (response.Success === true) {
loadBookingSlots();
$('.booking-detail-alert').hide();
$('#alertBookingSuccess').show();
}
else {
handleBookingError(response);
}
}).fail(function (response) {
handleBookingError();
});
}
I don't really know Javascript so anything helps, thank you all.
