The three major U.S. stock indexes closed Friday to post their second straight week of gains.