Aggiornato Cloudscraper:

(Fix per Il Genio dello Streaming)
This commit is contained in:
Alhaziel01
2020-04-23 16:46:11 +02:00
parent 04d86640d6
commit 03ff4bc0be
6 changed files with 119 additions and 19 deletions

View File

@@ -54,7 +54,7 @@ except ImportError:
# ------------------------------------------------------------------------------- #
__version__ = '1.2.32'
__version__ = '1.2.34'
# ------------------------------------------------------------------------------- #
@@ -102,6 +102,7 @@ class CloudScraper(Session):
self.debug = kwargs.pop('debug', False)
self.delay = kwargs.pop('delay', None)
self.cipherSuite = kwargs.pop('cipherSuite', None)
self.ssl_context = kwargs.pop('ssl_context', None)
self.interpreter = kwargs.pop('interpreter', 'native')
self.recaptcha = kwargs.pop('recaptcha', {})
self.allow_brotli = kwargs.pop(
@@ -134,7 +135,8 @@ class CloudScraper(Session):
self.mount(
'https://',
CipherSuiteAdapter(
cipherSuite=self.cipherSuite
cipherSuite=self.cipherSuite,
ssl_context=self.ssl_context
)
)
@@ -253,7 +255,7 @@ class CloudScraper(Session):
resp.headers.get('Server', '').startswith('cloudflare')
and resp.status_code in [429, 503]
and re.search(
r'action="/.*?__cf_chl_jschl_tk__=\S+".*?name="jschl_vc"\svalue=.*?',
r'<form id="challenge-form" action="/.*?__cf_chl_jschl_tk__=\S+"',
resp.text,
re.M | re.DOTALL
)
@@ -340,12 +342,11 @@ class CloudScraper(Session):
"Cloudflare IUAM detected, unfortunately we can't extract the parameters correctly."
)
payload = OrderedDict(
re.findall(
r'name="(r|jschl_vc|pass)"\svalue="(.*?)"',
formPayload['form']
)
)
payload = OrderedDict()
for challengeParam in re.findall(r'<input\s(.*?)>', formPayload['form']):
inputPayload = dict(re.findall(r'(\S+)="(\S+)"', challengeParam))
if inputPayload.get('name') in ['r', 'jschl_vc', 'pass']:
payload.update({inputPayload['name']: inputPayload['value']})
except AttributeError:
self.simpleException(