Optical Properties and Collective Excitations in MoS2 and NbSe2 in the 1.7 to 30 eV Range