aggiornato cloudscraper (fix piratestreaming)

This commit is contained in:
marco
2020-04-29 11:35:18 +02:00
parent 34b72249e7
commit 7d32bde60d
5 changed files with 55 additions and 18 deletions

View File

@@ -28,6 +28,7 @@ from .exceptions import (
CloudflareLoopProtection,
CloudflareCode1020,
CloudflareIUAMError,
CloudflareChallengeError,
CloudflareReCaptchaError,
CloudflareReCaptchaProvider
)
@@ -54,7 +55,7 @@ except ImportError:
# ------------------------------------------------------------------------------- #
__version__ = '1.2.34'
__version__ = '1.2.35'
# ------------------------------------------------------------------------------- #
@@ -265,6 +266,27 @@ class CloudScraper(Session):
return False
# ------------------------------------------------------------------------------- #
# check if the response contains new Cloudflare challenge
# ------------------------------------------------------------------------------- #
@staticmethod
def is_New_IUAM_Challenge(resp):
try:
return (
resp.headers.get('Server', '').startswith('cloudflare')
and resp.status_code in [429, 503]
and re.search(
r'cpo.src="/cdn-cgi/challenge-platform/orchestrate/jsch/v1"',
resp.text,
re.M | re.DOTALL
)
)
except AttributeError:
pass
return False
# ------------------------------------------------------------------------------- #
# check if the response contains a valid Cloudflare reCaptcha challenge
# ------------------------------------------------------------------------------- #
@@ -318,6 +340,12 @@ class CloudScraper(Session):
'Cloudflare has blocked this request (Code 1020 Detected).'
)
if self.is_New_IUAM_Challenge(resp):
self.simpleException(
CloudflareChallengeError,
'Detected the new Cloudflare challenge.'
)
if self.is_reCaptcha_Challenge(resp) or self.is_IUAM_Challenge(resp):
return True