In some real-time Internet of Things (IoT) applications, the timeliness of sensor data is very important for the performance of a system. How to collect the data of sensor nodes is a problem to be solved for an unmanned aerial vehicle (UAV) in a specified area, where different nodes have different timeliness priorities. To efficiently collect the data, a guided search deep reinforcement learning (GSDRL) algorithm is presented to help the UAV with different initial positions to independently complete the task of data collection and forwarding. First, the data collection process is modeled as a sequential decision problem for minimizing the average age of information or maximizing the number of collected nodes according to specific environment. Then, the data collection strategy is optimized by the GSDRL algorithm. After training the network using the GSDRL algorithm, the UAV has the ability to perform autonomous navigation and decision-making to complete the complexity task more efficiently and rapidly. Simulation experiments show that the GSDRL algorithm has strong adaptability to adverse environments, and obtains a good strategy for the UAV data collection and forwarding.