Skip to content

Commit

Permalink
fix recaptcha behaviour if PUPPETEER_INCLUDE_META=False
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsnq committed Jan 19, 2024
1 parent 6c82cdb commit ba3f517
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scrapypuppeteer/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,18 @@ def process_response(self,
if not isinstance(response, PuppeteerResponse): # We only work with PuppeteerResponses
return response

if request.meta.get('dont_recaptcha', False): # Skip such responses
puppeteer_request = response.puppeteer_request
if puppeteer_request.meta.get('dont_recaptcha', False): # Skip such responses
return response

if request.meta.pop('_captcha_submission', False): # Submitted captcha
if puppeteer_request.meta.pop('_captcha_submission', False): # Submitted captcha
return self.__gen_response(response)

if request.meta.pop('_captcha_solving', False):
if puppeteer_request.meta.pop('_captcha_solving', False):
# RECaptchaSolver was called by recaptcha middleware
return self._submit_recaptcha(request, response, spider)

if isinstance(response.puppeteer_request.action,
if isinstance(puppeteer_request.action,
(Screenshot, Scroll, CustomJsAction, RecaptchaSolver)):
# No recaptcha after this action
return response
Expand Down

0 comments on commit ba3f517

Please sign in to comment.