From a0b042ea2357b332ed03fddf3455122688867b37 Mon Sep 17 00:00:00 2001 From: yujiosaka Date: Sun, 10 Jun 2018 18:04:37 +0900 Subject: [PATCH] fix(hccrawler): allow-low-level-access --- docs/CHANGELOG.md | 7 +++++++ lib/hccrawler.js | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 539f7e20..8e96afa9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,9 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + - Set `previousUrl` to `onSuccess` argument. - Set `options`, `depth`, `previousUrl` to errors. +### Fixed + +- Fix a bug of not marking skipped requests correctly. +- Fix `requestfinished` event's argument as described in the [API reference](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/API.md). + ## [1.6.0] - 2018-05-14 ### Added diff --git a/lib/hccrawler.js b/lib/hccrawler.js index fef7ad27..0cfd2ae5 100644 --- a/lib/hccrawler.js +++ b/lib/hccrawler.js @@ -336,14 +336,14 @@ class HCCrawler extends EventEmitter { try { const res = await crawler.crawl(); await crawler.close(); + this.emit(HCCrawler.Events.RequestFinished, options); const requested = await this._checkRequestedRedirect(options, res.response); - if (requested) return []; - extend(res, { options, depth, previousUrl }); - this.emit(HCCrawler.Events.RequestFinished, res); - await this._success(res); await this._markRequested(options); await this._markRequestedRedirects(options, res.redirectChain, res.response); + if (requested) return []; + extend(res, { options, depth, previousUrl }); this._exportLine(res); + await this._success(res); return res.links; } catch (error) { await crawler.close();