Not sure if an automation, but a European marathon has an official resale platform which is first come first serve, which in practice means resale tickets are snatched up almost instantly.
I built a cron job which checked the page every minute, and sent a push notification to my phone when the page changed.
I probably could have optimised it further, but this was sufficient for me to secure a ticket.