Galactic and extra-galactic sources produce X-rays that are often absorbed by molecules and atoms in giant molecular clouds (GMCs), which provides valuable information about their composition and physical state. We mimic this phenomenon with a laboratory Z-pinch X-ray source, which is impinged on neutral molecular gas. The novel technique produces a soft X-ray pseudo continuum using a pulsed-current generator. The absorbing gas is injected from a 1 cm long planar gas-puff without any window or vessel along the line of sight. An X-ray spectrometer with a resolving power of λ/∆λ ∼420, comparable to that of astrophysical space instruments, records the absorbed spectra. This resolution clearly resolves the molecular lines from the atomic lines; therefore, motivating the search of molecular signature in astrophysical X-ray spectra. The experimental setup enables different gas compositions and column densities. K-shell spectra of CO2, N2 and O2 reveal a plethora of absorption lines and photo-electric edges measured at molecular column densities between ∼10 16 cm −2 -10 18 cm −2 typical of GMCs. We find that the population of excited-states, contributing to the edge, increases with gas density.