The invention belongs to the technical field of robots, and provides a welding robot capable of automatically identifying and tracking a welding line. The welding robot comprises a walking vehicle, a horizontal box body, a vertical box body, a horizontal and vertical tracking execution mechanism, a front vision sensor, a rear vision sensor, a welding gun mechanism and a computer control system; the horizontal box body and the vertical box body are arranged on the walking vehicle in a rear and front manner, the horizontal and vertical tracking execution mechanism is connected with a connecting plate and is fixedly arranged on the upper surface of the walking vehicle, the front vision sensor is mounted on the front side of the vertical box body, and a computer can be connected with the front vision sensor, the rear vision sensor, the walking vehicle and the horizontal and vertical tracking execution mechanism through cables, wherein the front vision sensor and the rear vision sensor can obtain the geometrical shape and the position information of the welding line. According to the welding robot, the geometrical shape of the welding line can be automatically identified, the pipeline welding bead number, the layer number and the tracking motion of the walking vehicle can be automatically planned through the computer, and stability and optimization of the welding quality can be ensured.