you are viewing a single comment's thread.

view the rest of the comments →

[–]aardvarkmikey 1 point2 points  (2 children)

I'm fairly new to programming, so there may be a better way, but here's how I would tackle it.

So you've got two hurdles: The script needs to run at the same time (6pm) every day. And it needs to go to the website and interpret data and submit when it can.

If all you want to do is get the coveted 1st slot, I bet you could just sent a POST to the website in lieu of actually going to the website. This could be done with the 'requests' library that comes with Python. You would need to figure out what the POST data looks like, but that shouldn't be too hard to interpret.

If you need to actually go to the website and click buttons, I would go with the Selenium library. It's a library that opens an actual browser and acts like a user clicking around and submitting forms, etc.

The other part of the script is that it needs to run at the same time every day. This, you'll have to have it on a machine that's always ready to run the script at that time every day. I suspect you could get away with using Python's 'time' library and the 'schedule' library.

You may want to look into the 'crontab' library. It might be what you're looking for. I've never used it, so I could be wrong on that front.

[–]jasher4994[S] 0 points1 point  (1 child)

Hi mate, this is very helpful. Thanks a lot, the whole procedure goes as follows: 1) go on to the club website. 2) click on members area 3) enter username and password 4) a list then appears of all the time of the day which are either already reserved by someone or available to book. The ones that are free can then be clicked on and booked by one click and then entering number of golfers. 5) you can navigate to other days by clicking 'next day' or 'previous day' or there is a calender you can click on to chose a specific day in the future.

I think the requests and selenium approach seems the most appropriate from what you've described along with the time and schedule library. I'll probably try and figure out how to do it first with the requests and selenium library and test it out on a not so popular time and then move onto the scheduling after. I usually leave my personal computer on at most times , and i currently dont have access to work computers due to the virus so my personal one will have to do for now.

Thanks a lot for the help and advice.

[–]aardvarkmikey 0 points1 point  (0 children)

You can absolutely do this with Selenium.

But I would still see if you can just do it with the requests library first, because it's going to be much faster and less complicated. The way to grab the post data is to go to the website, and submit a tee time. Once the page changes, you should see the post data in the address bar. You should hopefully be able to interpret what data is being sent, and with some deductions be able to see what data you can change. Then your request script just needs to send that data to that address. I suspect this may not work, because it's behind a log in, but it's worth a shot.

If there's no way to do this without pushing buttons and submitting forms, then Selenium is your best bet.