Hiya,
You can only buy Brazilian bus tickets online if you are in possession of a Brazilian ID card (i.e if you are Brazilian - which I'm guessing you're not

) You can but tickets for the day of travel, directly at the bus station (or via your hostel/hotel accommodation in Rio) As long as it's not a busy period (Christmas/New Year/Carnaval) you can get a ticket easily.
The buses run every day and you'll have a couple of options available to you - just ask in your hostel for the timetable

(It takes approx. 22 hours direct by bus)