✔ 最佳答案
Main from the spectrum of the light of the star / planet. Different element / chemical will absorb different frequency of the light. When we received the ligth emmited / reflected from the star / planet, we extract the spectrum, to find which frequencies are missing. You can find of absorption spectrum of different chemicals / elements on web. The simplest way to extracted a spectrum, is to use a prism like in primary school to see the compose of sun light.
The astronomers get the information of the star / planet now, are the light come from the star / planet in past. eg, For a star is 60 ly (light year) away from us, the light received now is the information of that star at 60 years ago. The situation of that star at this moment need to travel 60 years to us.
We are in fact looking in the past of the stars.