Can I buy a domain that used to have spam on it and still rank?

Can I buy a domain that used to have spam on it and still rank?