Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
ahmad-zuhd:1167ʿAbdullāh > Abū Bakr > Abū Usāmah > Khālid b. Majdūʿ > Anas

[Machine] I heard Anas saying, "When you meet a woman, close your eyes until she passes by."  

الزهد لأحمد:١١٦٧حَدَّثَنَا عَبْدُ اللَّهِ حَدَّثَنَا أَبُو بَكْرٍ حَدَّثَنَا أَبُو أُسَامَةَ عَنْ خَالِدِ بْنِ مَجْدُوعٍ قَالَ

سَمِعْتُ أَنَسًا يَقُولُ إِذَا لَقِيتَ امْرَأَةً فَغَمِّضْ عَيْنَيْكَ حَتَّى تَمْضِيَ