The invention relates to the technical field of gate valve replacing devices, particularly to an expansion core type mechanical device for replacing a valve under pressure. The expansion core type mechanical device comprises a fixed rack, an ejector rod, a connecting disk, a pushing disk, a process flange and a sealing flange, wherein at least two double-thread screws are fixed between the fixed rack and the connecting disk, at least one hydraulic cylinder is fixed on the connecting disk, a penetrating hole is formed in the middle of the connecting disk, a piston rod is arranged in the hydraulic cylinder and fixed with the pushing disk together, the right end of the ejector rod is fixed on the pushing disk, and the middle of the ejector rod is located in the penetrating hole. The expansion core type mechanical device is reasonable and compact in structure and convenient to use, gate valves can be replaced under pressure, in the gate valve replacing process, the good sealing performance can be guaranteed, the pressure leakage can be prevented, and the pollution and killing of oil reservoirs due to well-killing gate valve replacement can be avoided, so that the resurrection operation of killed oil reservoirs is avoided, meanwhile, the pollution discharge operation of polluted oil reservoirs is avoided, and the oil and gas production cost is saved.