Oil and gas pipeline networks are a key link in the coordinated development of oil and gas both upstream and downstream. To improve the reliability and safety of the oil and gas pipeline network, inspections are implemented to minimize the risk of leakage, spill and theft, as well as documenting actual incidents. In recent years, unmanned aerial vehicles have been recognized as a promising option for inspection due to their high efficiency. However, the integrated optimization of unmanned aerial vehicle inspection for oil and gas pipeline networks, including physical feasibility, the performance of mission, cooperation, real-time implementation and three-dimensional (3-D) space, is a strategic problem due to its large-scale, complexity as well as the need for efficiency. In this work, a novel mixed-integer nonlinear programming model is proposed that takes into account the constraints of the mission scenario and the safety performance of unmanned aerial vehicles. To minimize the total length of the inspection path, the model is solved by a two-stage solution method. Finally, a virtual pipeline network and a practical pipeline network are set as two examples to demonstrate the performance of the optimization schemes. Moreover, compared with the traditional genetic algorithm and simulated annealing algorithm, the self-adaptive genetic simulated annealing algorithm proposed in this paper provides strong stability.