From 35c59031b42909c733fd95bc58ec429952af123f Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sat, 16 May 2020 13:57:16 +0200 Subject: [PATCH] Ultimate update for PyNyaaTa before turning to NodeJS --- pynyaata/connectors/cloudscraper.py | 63 +---------------------------- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 62 deletions(-) diff --git a/pynyaata/connectors/cloudscraper.py b/pynyaata/connectors/cloudscraper.py index 18429f3..8797eb0 100644 --- a/pynyaata/connectors/cloudscraper.py +++ b/pynyaata/connectors/cloudscraper.py @@ -1,64 +1,5 @@ -import re -from collections import OrderedDict -from urllib.parse import urlparse - -from cloudscraper import CloudScraper, CloudflareIUAMError, JavaScriptInterpreter +from cloudscraper import CloudScraper class CloudScraperWrapper(CloudScraper): - - def IUAM_Challenge_Response(self, body, url, interpreter): - try: - formPayload = re.search( - r'
.*?="challenge-form" ' - r'action="(?P.*?' - r'__cf_chl_jschl_tk__=\S+)"(.*?))', - body, - re.M | re.DOTALL - ).groupdict() - - if not all(key in formPayload for key in ['form', 'challengeUUID']): - self.simpleException( - CloudflareIUAMError, - "Cloudflare IUAM detected, unfortunately we can't extract the parameters correctly." - ) - - payload = OrderedDict() - for challengeParam in re.findall(r'', formPayload['form']): - inputPayload = dict(re.findall(r'(\S+)="(\S+)"', challengeParam)) - - if inputPayload.get('name') in ['r', 'jschl_vc', 'pass']: - if inputPayload.get('name') != "jschl_vc": - - payload.update({inputPayload['name']: inputPayload['value']}) - elif inputPayload.get('name') == "jschl_vc" and "jschl_vc" not in payload: - payload.update({inputPayload['name']: inputPayload['value']}) - - except AttributeError: - self.simpleException( - CloudflareIUAMError, - "Cloudflare IUAM detected, unfortunately we can't extract the parameters correctly." - ) - - hostParsed = urlparse(url) - - try: - payload['jschl_answer'] = JavaScriptInterpreter.dynamicImport( - interpreter - ).solveChallenge(body, hostParsed.netloc) - except Exception as e: - self.simpleException( - CloudflareIUAMError, - 'Unable to parse Cloudflare anti-bots page: {}'.format( - getattr(e, 'message', e) - ) - ) - - return { - 'url': '{}://{}{}'.format( - hostParsed.scheme, - hostParsed.netloc, - self.unescape(formPayload['challengeUUID']) - ), - 'data': payload - } + pass diff --git a/requirements.txt b/requirements.txt index 5a90a82..1868b5d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,5 @@ PyMySQL==0.9.3 requests==2.23.0 beautifulsoup4==4.9.0 python-dotenv==0.13.0 -cloudscraper==1.2.36 +cloudscraper==1.2.38 dateparser==0.7.4