Nanometer-scale measurements of photoabsorption spectra of individual defects in semiconductors