diff --git a/scrapypuppeteer/middleware.py b/scrapypuppeteer/middleware.py index f6c5852..4063e98 100644 --- a/scrapypuppeteer/middleware.py +++ b/scrapypuppeteer/middleware.py @@ -156,7 +156,9 @@ def process_response(self, request, response, spider): response_cls = self._get_response_class(puppeteer_request.action) if response.status != 200: - self.used_contexts[id(spider)].add(response_data['contextId']) + context_id = response_data.get('contextId') + if context_id: + self.used_contexts[id(spider)].add(context_id) return response return self._form_response(response_cls, response_data, diff --git a/setup.py b/setup.py index 185ef43..1b8503f 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='scrapy-puppeteer-client', - version='0.1.3', + version='0.1.4', description='A library to use Puppeteer-managed browser in Scrapy spiders', long_description=long_description, long_description_content_type="text/markdown",