Natural resources prices have been greatly affected by the Russian-Ukrainian war. Investors also pay special attention to the price of natural gas and oil. This paper introduces the Thermal optimal path (TOP) method and the Long Short-Term Memory (LSTM) model to investigate the dynamic lead-lag relationship between investor attention and natural resources prices for crude oil and natural gas.We find that during the war, the ability of investor attention to lead the prices of crude oil and natural gas become significantly stronger. Adding investor attention to the model significantly improves price prediction in the full sample. In addition, after the sample period is segmented according to the TOP method, the forecasting performance is greatly improved compared to the full sample. These findings indicate that traders and companies can incorporate investor attention into price predictions to further improve their trading strategies.