It is a long drawn aout process and I would strongly advise you think again about it unless you have some really pressing business or good experience of Russia. The dock area is at least 5 miles out of town and when we were there we were constantly warned by the guides not to stray away from the group due to pickpockets and muggers who prey on `rich` tourists. It seems a bizarre bthing to do when you could either go on an organised trip or hire a local guide who fixes the visas. Even by doing this it was a performance going through customs to get given ones visa for the day and certainly not a tourist friendly event. However once one was able to see all that St Petersburg had to offer it was well worth it.
If you really want one, you have to apply to the Russian embassy and they cost 56USD each. See Russian embassy website. I would not recommend going independently. If you go by ships tour or Russian tourist company tour, you are covered under a group visa which costs you nothing.
We will be in St Petersburg in September and have just booked a two day tour through Alla, go to www.alla-tour.com for full details and itineraries. The cost is $300 per person. They send lots of information and, as stated by Mr/Mrs Williams, they also arrange the group visa. The booking procedure is very easy and efficient and you can also keep in touch with them via a secure website if you need to ask any questions. Other operators are DenRus and Red October.