The word 'weigh' is not the one to use, since weight implies that a body is being acted upon a gravitational force. What you probably want to know is how astronomers can figure out the MASS of an astronomical body!
The answer is...we use a simple equation in physics...Kepler's Third Law. The mass of a planet is related to the orbital period and distance of its satellite. Except for Mercury and Venus, all planets have satellites. For these two planets, flybys of artificial spacecraft were able to make the equivalent gravimetric measurements in the 1960's. Here's an example of how the mass of the Earth is obtained using the Moon.
The basic formula can be estimated by balancing gravitational and centrifugal forces in a circular orbit. If the satellite's mass is given by the symbol m, its speed as V, its orbit radius as r, and the planet's mass by M,
2 m V G M m ---- = --------- (call this Equation 1) 2 r r Notice that the mass of the satellite, m, cancils out from both sides! And since the average speed of the satellite in its orbit is the orbit circumference divided by the orbit time, 2 x pi x r V = ----------- ( call this Equation 2) T where r = radius of orbit and T = orbit period. If you eliminate V from the first equation substituting Equation 2 2 3 4 pi r M = ------------------- (call this Equation 3) 2 G T
We have now rendered the mass of the planet, M, in terms of the period, T, and radius, r, of its satellites orbit!
For the Moon, r = 384,000 km (3.8 x 10^10 centimeters) and T = 27 days (27x86,400 seconds = 2.3 x 10^6 seconds), you get from the above equation ( with G = 6.6 x 10^-10) that the mass of the Moon = 6.2 x 10^25 grams. Actual more careful determinations from such things as the Apollo missions give 7.3 x 10^25 grams!!
You can apply Equation 3 to any 2-body system in which the mass of the satellite is much smaller than the mass of the body it is orbiting. In fact all of the planets except Mercury and Venus can be 'weighed' this way...even stars and galaxies for which you know their separations and orbital velocities. For instance, the Sun has an orbital speed of about 250 kilometers/sec at a distance from the Milky Ways center of about 28,400 light years. With a little work and Equation 1, you can figure out the mass of the Milky Way!