Skip to content

Commit

Permalink
Release 1.2.2
Browse files Browse the repository at this point in the history
Fix reCaptcha class solveCaptcha params
  • Loading branch information
VeNoMouS committed Oct 9, 2019
1 parent 99cf821 commit 6049f10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cloudscraper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# ------------------------------------------------------------------------------- #

__version__ = '1.2.1'
__version__ = '1.2.2'

# ------------------------------------------------------------------------------- #

Expand Down
21 changes: 10 additions & 11 deletions cloudscraper/reCaptcha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

0 comments on commit 6049f10

Please sign in to comment.