|MadSci Network: Astronomy|
That's a terrific question! Figuring out what planets (and, for that matter, stars, nebulae, and almost everything astronomical) are made of is not straight-forward as working out what's in, say, a test-tube. After all, we've only actually put probes onto (or into) a few planets and nothing at all outside our solar system. So how do astronomers do it?
The answer lies in the one of the many amazing things to do with light. (Come to think of it, light seems to be the answer most of the time in astronomy.) In this case, we use spectroscopy, which is studying the light from an object by the different wavelengths. Every atom and every molecule like to emit or absorb light at certain wavelengths and not at others. This means that by breaking the light from an object into it's various wavelengths (for visible light, different wavelengths is the same as different colors; for other parts of the spectrum – ultraviolet, x-rays, gamma rays, infrared, and radio – we just say "wavelengths"), we can look for the fingerprints of different atoms and molecules.
By now you've guessed that this is exactly how we work out what stars and planets are made of, for the most part. (This technique is even used for the Earth to map out vegetation types and other surfaces from orbit. Besides getting useful information in its own right, this also allows us to check our ability to interpret spectra.)
The exception is for a small number of planets and one moon on which we have landed or sent probes: Earth, our Moon, Venus, Mars, and Jupiter. For Earth and the Moon we have been able to bring rock samples back into labs to be studied. Mars and Venus have both had visits from landers which were designed with instruments to help work out what kinds of rocks are on the surface. What kinds of instruments? Well, geologists use ordinary cameras for some of this (they can often tell a lot about rocks just by looking at them. But much more information is gleaned from instruments like the Alpha Proton X-Ray Spectrometer on Mars Pathfinder. These instruments bombard the rocks with alpha particles (a fancy name for helium nuclei) and then look at the alpha particles, x-rays, or protons that come back at the detectors. By studying the energies of the particles that come back, scientists can determine what is in the rocks. (It's a lot like spectroscopy with light, actually.) Finally, when the Galileo spacecraft arrived at Jupiter in 1995, it dropped a small probe into that planet's atmosphere to measure the composition. The results were surprising and intriguing, so needless to say scientists would love to send more probes!
We're currently planning to have a robotic sample return mission to Mars in the near future so that we can bring some of those rocks into our labs here on Earth. (We do have a few Mars rocks already, which came to us as meteorites. Unfortunately, we don't know where on Mars they came from exactly and we're not always quite sure what has happened to them since they left Mars.)
It is also worth noting that another body is about to be added to the above list of "visited up close and personal" objects: Saturn's moon, Titan. The Cassini spacecraft will arrive at Saturn in July of this year and is scheduled to drop the Huygens probe into Titan in December. I'm sure that we'll have interesting and surprising things to share about what we learn not long after that.
So review: we've been able to probe a few planets closely, but most of what we know about planet compositions comes from spectroscopy. If you want to learn more about this, I highly recommend The New Solar System (Beatty, Petersen, and Chaikin, editors). This book provides a lot more detail about measurements, but it's written for non-scientists.
Try the links in the MadSci Library for more information on Astronomy.