             page.close()
             ph.exit()
             reject reason
+
+      .catch (resaon) ->
+        ph.exit()
+        reject reason
+
+    .catch (reason) ->
+      reject reason

      url.substring(0, HTTP.length) isnt HTTP
    url = BASE_URL + url

  new Promise (resolve, inject) ->

    phantom.create().then (ph) ->


                for read_more in document.getElementsByClassName("read-more")
                  read_more.firstElementChild.click()

                document.body.dataset.youtubeCommentScraper = "ready"

          .then ->
            # Check data-youtube-comment-scraper is ready, which means all pages
            # are loaded and all collapsed comments are expanded.
            # If not, wait more 1000 msec.
            new Promise (resolve, reject) ->
              do get_body = ->
                page.evaluate ->
                  if document.body.dataset.youtubeCommentScraper is "ready"
                    document.body.innerHTML
                .then (html) ->
                  if html
                    resolve html
                  else
                    setTimeout get_body, 1000

                .catch (reason) ->
                  reject reason

          .then (html) ->
            $ = cheerio.load html
