From Sahih Bukhari (Hadith 3381):
Narrated Ibn `Umar:Allah's Messenger (ﷺ) said, "Do not enter the ruined dwellings of those who were unjust to themselves unless (you enter) weeping, lest you should suffer the same punishment as was inflicted upon them
Reference: Bukhari 3381