Figuring out how to find commercial properties with code violations is going to take some initial work on your part because this varies by state and county across the country.
The nice thing about this is that because this takes some extra effort to figure out, most investors won't take the time to find out how to tap into this source of potential commercial deals.
You're looking for a way to know about apartments and mobile home parks that may have health code violations.
Try searching online by entering "Code violations + name of your county"
You might find that your county lists these online.
If that doesn't work, call the county and tell them that you're looking at buying a few different apartment buildings and you need to verify whether there are any previous or current health code violations. I like to include a little speech about how we fix up properties to improve the county, etc.
If the person can't help you, ask them to send you to someone who can, or you may need to thank them and then call back another day and hopefully you end up with someone who's able to point you to the right department.
You get extra points if you can create rapport with someone who works in the health department. I've found that finding a way to truthfully give them some praise for all the hard work they do goes a long way.