Tunable diode laser absorption spectroscopy (TDLAS) is often used to detect the industrial processing gas component, but the concentration measurement in the field is easily affected by the surrounding temperature. Firstly, the effect of temperature on absorption spectrum was analyzed. Taking methane as an example, DFB laser with 1654nm was used to collect the concentration under temperature from 253K to 323K (with the interval of 10K for each point) based on WMS method. The results showed that the maximum relative error was 25%. Based on the experimental data, the correction formula of second harmonic full waveform was fitted, and the gas detection system with temperature compensation was constructed at the same time. The experimental results illustrated that the maximum relative error under the same test conditions was reduced to less than 5%, and the detection accuracy were significantly improved under variable temperature environment, which provided the guarantee for TDLAS online monitoring and broadened the use scenario of the technology.