onlookers or spectators

Is there any difference in the use of onlookers and spectators.-If there is any, would you give some examples?
Many thanks

Spectators are a group of people who have gathered for the specific purpose of watching an event.
“The spectators were thrilled by the acrobats’ performance.”

Spectators may also be onlookers. However, the term ‘onlookers’ also refers to a more informal gathering. A group of people who witness an event by luck, because they just happen to be there when it is taking place.
" A crowd of onlookers gathered on the corner and watched the firefighters struggling to control the flames."