The Soret effect is a significant factor in various scenarios, with thermodiffusion in binary systems serving as a common method for the study. Most research focuses rarely on the distribution characteristics of components in diffusion systems; and Soret coefficients in the porous media could not be obtained by typical methods based on the thermodiffusion column, which are particularly important in the field of oil and gas development. Moreover, experiments on ground conditions have struggled to determine the Soret coefficient accurately due to the convective effect caused by gravity differentiation. The thermodiffusion behavior of n-pentane (C5) and n-heptane (C7) binary mixtures in both bulk and porous media conditions have been investigated, aiming to provide corrected coefficients that mitigate the influence of gravity using theoretical derivation. A new method was proposed to calculate the Soret coefficients in this work by establishing a model based on gas chromatography technology. Dynamic variation of component concentration along the path was studied, and the corresponding Soret coefficients were calculated and analyzed in parallel. The results indicate that the concentration and temperature exhibit a logarithmic relationship with the distance from the heat source. The Soret coefficient values obtained from measurements in porous media are closer to the theoretically corrected values, which do not account for gravity effects. Additionally, as the permeability decreases, the counteracting effect of porous media on convection becomes more pronounced. Therefore, it presents a novel method for accurately measuring the Soret coefficient that ignores convection to some extent.