The invention provides a nanofiber foam based oil gas trapping device and a preparation method thereof. The nanofiber foam based oil gas trapping device is characterized in that: it includes an gas collection pump in connection with a gas delivery pipe, the gas delivery pipe is connected to an oil-gas trapping assembly, the oil-gas trapping assembly is connected to an exhaust pipe and a collection pipe, and the collection pipe is connected to an oil substance recycling bin. Specifically, the oil-gas trapping assembly includes a protective box, and the protective box is internally provided with a nanofiber based foam material. The nanofiber foam based oil gas trapping device has the characteristics of simple preparation process, low cost, convenient operation, integrated oil-gas adsorption recovery, high efficiency and continuity, and has wide application at gas stations, oil plants, wharfs and other sites, and in manufacturing industry, surface coating industry and other fields.