SPN extraction script