Scope of the crawl
Same-origin links only. An external link is someone else's server, and its status belongs in a link-checking task, not a page test.
Where the loop is too slow
A page with hundreds of links makes the loop slow. Run the crawl on the pages users reach, and keep the deep crawl as a separate slower job.