diff --git a/scrapypuppeteer/middleware.py b/scrapypuppeteer/middleware.py index 4063e98..b7a5f56 100644 --- a/scrapypuppeteer/middleware.py +++ b/scrapypuppeteer/middleware.py @@ -312,14 +312,17 @@ def process_response(self, return response # Any puppeteer response besides RecaptchaSolver's PuppeteerResponse - return self._solve_recaptcha(response) + return self._solve_recaptcha(request, response) - def _solve_recaptcha(self, response): + def _solve_recaptcha(self, request, response): self._page_responses[response.page_id] = response # Saving main response to return it later recaptcha_solver = RecaptchaSolver(solve_recaptcha=self.recaptcha_solving, close_on_empty=self.__is_closing(response, remove_request=False)) return response.follow(recaptcha_solver, + callback=request.callback, + cb_kwargs=request.cb_kwargs, + errback=request.errback, meta={'_captcha_solving': True}, close_page=False) @@ -339,6 +342,7 @@ def _submit_recaptcha(self, request, response, spider): return self.__gen_response(response) return response.follow(action=submitting, callback=request.callback, + cb_kwargs=request.cb_kwargs, errback=request.errback, close_page=self.__is_closing(response), meta={'_captcha_submission': True})