   /// The urls of pages found during crawling, but yet to visit.
   var pagesToVisit: Set<URL>
 
-  /// This callback is fired each time the crawler is about to visit a new
-  /// webpage.
-  let visitingCallback: ((URL) -> Void)?
-
-  /// This callback is fired each time the parser finds `wordToSearch` in a
-  /// web page (fired up to one time per page).
-  let wordFoundCallback: (URL) -> Void
-
-  /// The completion block called when the crawler ends its execution.
-  let completion: (Int) -> Void
+  /// The object that acts as the delegate of the crawler.
+  public weak var delegate: CrawlerDelegate?
 
   /// The current `URLSessionDataTask`, if any.
   var currentTask: URLSessionDataTask?

    guard
      visitedPages.count < maximumPagesToVisit,
      let pageToVisit = pagesToVisit.popFirst() else {
      completion(visitedPages.count)
      return
    }


  func parse(document: String, url: URL) {
    func find(word: String, from document: String) {
      guard document.contains(word) else { return }
      delegate?.crawler(self, didFindWordAt: url)
    }

    func collectLinks(from document: String) -> [URL] {
