It is called spectroscopy. All objects in this universe give out a spectrum of light. On Earth, we have analyzed and categorized all such spectrum for different chemical elements. Astronomers analyze the spectrum of the planet to decide what the planet is made of.
If it is about the core, you could take a reasonable stab at the composition with available spectral data. With a little more information like the mass of the planet, it is marginally safe to make assumptions about the planet’s core.