Black objects do not attract sunlight, per se, but instead absorb rather than reflect light. Light absorbs changes from light energy to heat energy, causing black objects to become hotter in sunlight than more reflective objects.
Pure sunlight is actually a combination of all the colors in the spectrum. An object's color results from the wavelengths of light it reflects instead of absorbs. A blue object is blue because it absorbs all the other colors of light except for blue. White objects reflect the full spectrum of light's colors. Black objects reflect no colors. Black objects therefore lack color, absorbing rather than reflecting all colors of light.