The quality of captured wild pets is random. As of patch 5.1, upon entering a battle the Pet Battle UI shows the quality of a wild pet (idicated by a color-coded border around its icon). If you're farming a specific quality, if you forfeit the match your team will incur a small damage penalty (roughly 10%). There is no accurate way to determine a pet's quality prior to the start of a battle.
You are right here. The Rematch string is part of the Info box, and as such it should be parsed correctly. (The string that contains the correct and breed/damage-specific min health requirements). This should be enough, but, I think there are also folks that aren’t using Rematch. They also should know of the type-specific min health requirements. Unfortunatly the default forms of the page don’t offer any detailed entries for the min health. They only offer one entry (for all damage types), and I always put the worst-case min health there (for pets that are weak against the expected damage type)