Is it possible to get the attachments of a page, but only the ones that are showing in the page?

In a confluence page I need to differentiate the attachments the page has, vs the attachments that are actually used in the page with the text. All the addons in the market that search for unused attachments are not working for us, so we might need a custom solution.
I have seen how I can get all the attachments of the page but I do not know how I can get a list of only the ones being referenced on the page. I think the only solution would be to scan the page for attachment extensions or look for the tag attachment.
has anyone tried this before? I am not sure what would be the best approach…

What have you tried so far? Any ideas?

One thing that comes in to my mind:

  • Extract used attachments from the content
  • Compare them to all attached attachments