How do you weigh a planet?

How do you weigh a planet?