By the turn of the century it was well known that an emission spectrum existed for the various elements. The experiment is easy: An element, such as hydrogen, is excited by an electrical potential until it gives off light. The emitted light is then passed through a prism - which separates it into its constituent wavelengths. The wavelengths are then recorded on light sensitive film.
Each element gives a unique spectrum. The position of the lines relative to one another changes from element to element and, as it turns out, from molecule to molecule. In essence, the emission spectrum is a fingerprint of the element/molecule that generates it.