Sorry, but prostitution is not illegal in Spain, just allegal.

Pimps are hardly treated because exploiting prostitutes is illegal.

Prostitutes who don't have legal residency are expelled.

The rest of the cases are not illegal except that they do some minor public order disturbance when they work at the streets.