How to create a script that can purchase tickets.

Just curious as to how this could be done. Just say I have an account with my billing info added and I just wanted the script to go out and purchase the tickets before they sell out. Any good library for this?