It's ultimately a cat and mouse game with many websites actively trying to sabotage archival efforts.
Unless this is a core functionality in something you're working on, most people will be better off using the SavePageNow API from archive.org and integrating with that. This is what I ultimately ended up doing for one of my projects.[1]