The wellhead gas recovery unit can use a low-pressure purification unit+CNG compressor system or a high-pressure purification system to complete the filling of CNG trailers based on the wellhead pressure. The unit has the advantages of strong reliability, wide application range, optimized and simplified process, easy operation and maintenance, convenient installation and transportation, reduced floor area, shortened construction cycle, fewer fixed facilities, low relocation costs, intelligent control, and fewer staffing. It effectively solves the problems of low production, rapid pressure drop, large fluctuation range, and high operating costs in the marginal well areas of oil and gas fields in the past.