There are a lot of departures every day (over 100 departures) on this route. So unless you're going around Chinese New Year in Feb/Mar, you should be able to just buy a ticket on the day of and get a seat without issues
Use Ctrip to look up the schedules. If you're really concerned about availability, you can always just book online. Again, Ctrip is probably the best website to book trains in China. Alternatively you can just go to any train station in China to book train tickets up to 30 days in advance. If you buy at the train station, bring cash and passport!
It's completely feasible to do day trips from Shanghai to Hangzhou, catching an early morning train there and an evening train back