Spectroscopy is cool! Basically whenever light shines through a thing, the thing can absorb or emit light, and that happens at specific wavelengths depending on what the thing is made of. You can get small spectroscope pretty cheap and play around with a bunch of hone experiments - a common lab project in class is putting salts in a flame and based on the spectra figuring out what atoms are in the salt. It's how we discovered helium must exist in the sun before actually finding any on earth. So basically we just do that, except on a planet that's far away. When it's between it's star and us, we look at the spectra of the light that goes through the planets atmosphere