I’m trying to automate my local library’s slot booker – they have private spaces that you can book but they pretty much get booked early morning. I wrote a script using selenium and that works but for that I’ll keep to keep my laptop open, or get a virtual machine with chrome but I want to deploy it on an ec2 instance as it has become a side project of mine. For this I tried to use requests to hit their dates api to get the available date but their website as cookies and csrf token which usually gives me 403 forbidden or an error msg saying you need to sign in first. The flow of my script is like this 1. Initializing session by “curl -s -c -H “Connection:keep-alive” sign in url – just copied this api from network tab – added my username and password 2. Save the response from 1 to get the session cookie and csrf token 3. Now pass the token and csrf to the curl to hit the sign in link but also send username password and sign in param as payload 4. Now here is where I stumbled – after successful sign in it redirects to the accounts page where I can schedule a space for a specific date – after signing in I hit the dates api (got from the networks tab) with the same cookie and csrf I used for login but I can’t get the list of dates
I am able to get the list of dates if I open chrome manually sign in grab the cookie and csrf token from the session and use that to pass on to the curl statement which makes me wonder if my script is unable to grab them
Any advice/help would be greatly appreciated
submitted by /u/symrin
[link] [comments]
r/learnpython I’m trying to automate my local library’s slot booker – they have private spaces that you can book but they pretty much get booked early morning. I wrote a script using selenium and that works but for that I’ll keep to keep my laptop open, or get a virtual machine with chrome but I want to deploy it on an ec2 instance as it has become a side project of mine. For this I tried to use requests to hit their dates api to get the available date but their website as cookies and csrf token which usually gives me 403 forbidden or an error msg saying you need to sign in first. The flow of my script is like this 1. Initializing session by “curl -s -c -H “Connection:keep-alive” sign in url – just copied this api from network tab – added my username and password 2. Save the response from 1 to get the session cookie and csrf token 3. Now pass the token and csrf to the curl to hit the sign in link but also send username password and sign in param as payload 4. Now here is where I stumbled – after successful sign in it redirects to the accounts page where I can schedule a space for a specific date – after signing in I hit the dates api (got from the networks tab) with the same cookie and csrf I used for login but I can’t get the list of dates I am able to get the list of dates if I open chrome manually sign in grab the cookie and csrf token from the session and use that to pass on to the curl statement which makes me wonder if my script is unable to grab them Any advice/help would be greatly appreciated submitted by /u/symrin [link] [comments]
I’m trying to automate my local library’s slot booker – they have private spaces that you can book but they pretty much get booked early morning. I wrote a script using selenium and that works but for that I’ll keep to keep my laptop open, or get a virtual machine with chrome but I want to deploy it on an ec2 instance as it has become a side project of mine. For this I tried to use requests to hit their dates api to get the available date but their website as cookies and csrf token which usually gives me 403 forbidden or an error msg saying you need to sign in first. The flow of my script is like this 1. Initializing session by “curl -s -c -H “Connection:keep-alive” sign in url – just copied this api from network tab – added my username and password 2. Save the response from 1 to get the session cookie and csrf token 3. Now pass the token and csrf to the curl to hit the sign in link but also send username password and sign in param as payload 4. Now here is where I stumbled – after successful sign in it redirects to the accounts page where I can schedule a space for a specific date – after signing in I hit the dates api (got from the networks tab) with the same cookie and csrf I used for login but I can’t get the list of dates
I am able to get the list of dates if I open chrome manually sign in grab the cookie and csrf token from the session and use that to pass on to the curl statement which makes me wonder if my script is unable to grab them
Any advice/help would be greatly appreciated
submitted by /u/symrin
[link] [comments]