KABUL, Afghanistan — The Taliban attacked a U.S. Consulate in western Afghanistan with car bombs and guns on Friday, killing at least four Afghans but failing to enter the compound or hurt any Americans.