ספר המדות, Vision Vision · ט
Sefer HaMiddot 2348
ט. כְּשֶׁאָדָם יוֹצֵא לַשּׁוּק וּמִתְיָרֵא, שֶׁלּא יָבוֹא לִידֵי הִרְהוּר עַל יְדֵי הָרְאִיָּה, שֶׁיִּרְאֶה נָשִׁים יָפוֹת, יאמַר הַפָּסוּק "הֵן אֶרְאֶלָּם צָעֲקוּ חוּצָה" וְכוּ', וְעַל יְדֵי זֶה יִנָּצֵל מֵרְאוֹת.
9. When a person goes out to the marketplace and fears he will come to (improper) thoughts through his vision -- that he will see beautiful women, he should say the verse: "Hen errelum tzaaku chutza malachei shalom mar yivkuhyun (Yeshiyahu 32:7 -- Yea, the angels screamed outside and the angels of peace cry bitterly), and through this he will be saved from seeing.