Is there a way to programmatically clean/Redactorize HTML?
The Purify setting for the Rich Text field will run the data through HTMLPurifier, which will do its best to try and remove any malicious code from the data.

I think what you're seeing is Redactor itself cleaning the rogue HTML elements before submitting to POST/Craft.

I think it's probably going to be easier trying to clean your HTML with some custom logic/regex before saving rather than trying to figure out how to spin up Redactor to do the cleaning.