Skip to content

Commit

Permalink
fix: context id may be missing on error responses (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsnq authored Sep 11, 2023
1 parent 642d0fb commit 89d4bf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scrapypuppeteer/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 89d4bf2

Please sign in to comment.