How to count bounced email against email address and update my email database

I don’t know much about miab internals so, if I had to get this working with no research, I would set up a rule in RoundCube to route all the bounces to a specific folder, then interrogate that folder using Python (imaplib), extract the email addresses and update my database accordingly.