I was looking at the DOM explorer in dev tools, and see on the web part there is a tag with class
ms-WPBody and attribute
webpartid="7722f3d5-e8da-4b3b-acc4-3bf3e6f9aba7" (for example). It seems to be different per instance of this web part on the same page too.
div.ws-WPBody and then grabbing the webpartid value.
Is this an ok way, or is there any issues or better ways?