jvolker / miq-nz-booking-tools

Tools to help booking a spot in New Zealand Managed Isolation and Quarantine. Automatically refreshes, checks and fills forms in the website to find and book the rare spots.
MIT License
83 stars 35 forks source link

Speeding up the date selection process #37

Open alexDrinkwater opened 3 years ago

alexDrinkwater commented 3 years ago

Right now it takes 5 seconds to see a new date and then once you click it you need to do a captcha on the newly reloaded page. We could open two pages, one that refreshes every 5 seconds to get the new dates while the other is "staged" where the user has already completed the captcha. When the reloading page finds a date, we can communicate that to the staged page with the date, enable the date and auto click the date via js and then click the next button. The only issue here is that captchas have a few minutes timeout after completing them so the user would need to redo the captcha every few minutes to gain this advantage.

alexDrinkwater commented 3 years ago

@stilljake Was wondering what your thoughts are on this?

alexDrinkwater commented 3 years ago

I've got a prototype where we could share dates that become available in realtime using firebase. The problem I see with that is people would be poaching dates of each other so I need a way to lock it down to only users that want specific dates (with some sort of max date limit). I would need to package it separately to not expose the api keys to prevent misuse. I'm not sure if its worth it but if we get enough people using it and sharing data each time they refresh it could increase the odds substantially.

stilljake commented 3 years ago

@stilljake Was wondering what your thoughts are on this?

I put something together already that takes a similar approach. I have one browser instance scraping dates through various proxies to avoid the rate limits, and then once a date is found the other instance is refreshed and selected. I never thought to simply enable the date and click it. That would probably work much faster. I was thinking it could be possible to even avoid the second instance by using using the Twitter streaming API to watch for posts from the twitter bot to fetch the available dates instead, but would probably need users to set up their own api keys and pass them to the app.

stilljake commented 3 years ago

I'm interested to hear more about how this sharing method would work too.

chrisneilsen commented 3 years ago

I agree that it's the delay between refreshes that is a major block to getting a date. This proposal seems like it would work, and I'd be keen to participate.

Another blockage is having to manually click the reCapcha. This could be (semi?) automated using SendInput to generate a mouse click. I've done a successful proof of concept, where I manually position the mouse over the reCapcha, and send a click, the reCapcha is passed.

This could be done in responce to an alert. Obviously, if reCapcha asks you to solve a picture, you are already too late. In my experience, if you don't click it too much, then it usually goes straight to the green tick.

I'd be ok with a solution that requires manual positioning of the mouse. But if the mouse could be moved to the right spot too, that'd be cool.

If this can be made to work, automating the click on "Next", and completing the following page could be automated too.

stilljake commented 3 years ago

It's also easy enough to fully automate clicking recaptcha and next. For recaptcha you need to switch page context to the recaptcha iframe, and then you can just do an element.click() on the checkbox. Then switch context back to the main page and click() the next button. I've done a proof of concept of this too. As long as recaptchas not asking you to solve anything it's fine.