Puppeteer【pyppeteer】 获取 http 请求的响应的结果

参考:https://www.lfhacks.com/tech/puppeteer-http-response

基于【pyppeteer】的玩法【python获取回调函数的值需使用单独的模块】https://pypi.org/project/promise/【此模块等待测试】

            def get_random_captcha_code(response: Response):
                nonlocal _captcha_code
                if "你期待的验证码url部分字符串" in response.url:
                    captcha_img_url = response.url
                    logging.warning(f"{self.spider_prefix}获取的图形验证码    captcha_img_url={captcha_img_url}")
                    _captcha_code = self.parse_captcha_by_upload_image(
                        captcha_img_url=captcha_img_url)
                    return True

                page.on("response", get_random_captcha_code)
                

猜你喜欢

转载自blog.csdn.net/weixin_43343144/article/details/112169558