diff --git a/cloudscraper/__init__.py b/cloudscraper/__init__.py index 4f6b588..8faae18 100644 --- a/cloudscraper/__init__.py +++ b/cloudscraper/__init__.py @@ -39,7 +39,7 @@ # ------------------------------------------------------------------------------- # -__version__ = '1.2.1' +__version__ = '1.2.2' # ------------------------------------------------------------------------------- # diff --git a/cloudscraper/reCaptcha/__init__.py b/cloudscraper/reCaptcha/__init__.py index 1f93277..c5dc90e 100644 --- a/cloudscraper/reCaptcha/__init__.py +++ b/cloudscraper/reCaptcha/__init__.py @@ -8,20 +8,20 @@ else: ABC = abc.ABCMeta('ABC', (), {}) -########################################################################################################################################################## - -BUG_REPORT = 'Cloudflare may have changed their technique, or there may be a bug in the script.' - -########################################################################################################################################################## +# ------------------------------------------------------------------------------- # captchaSolvers = {} +# ------------------------------------------------------------------------------- # + class reCaptcha(ABC): @abc.abstractmethod def __init__(self, name): captchaSolvers[name] = self + # ------------------------------------------------------------------------------- # + @classmethod def dynamicImport(cls, name): if name not in captchaSolvers: @@ -35,14 +35,13 @@ def dynamicImport(cls, name): return captchaSolvers[name] + # ------------------------------------------------------------------------------- # + @abc.abstractmethod def getCaptchaAnswer(self, site_url, site_key, reCaptchaParams): pass - def solveCaptcha(self, ret, reCaptchaParams): - try: - site_key = re.search('data-sitekey="(.+?)"', ret.text).group(1) - except Exception as e: - raise ValueError("Unable to parse Cloudflare\'s reCaptcha variable 'data-sitekey': {} {}".format(e.message, BUG_REPORT)) + # ------------------------------------------------------------------------------- # - return self.getCaptchaAnswer(ret.url, site_key, reCaptchaParams) + def solveCaptcha(self, site_url, site_key, reCaptchaParams): + return self.getCaptchaAnswer(site_url, site_key, reCaptchaParams)