diff --git a/cfscrape/__init__.py b/cfscrape/__init__.py index 29eba5e..b341e18 100644 --- a/cfscrape/__init__.py +++ b/cfscrape/__init__.py @@ -30,6 +30,8 @@ class CloudflareScraper(Session): def __init__(self, *args, **kwargs): + self.delay = kwargs.pop('delay', 5) + super(CloudflareScraper, self).__init__(*args, **kwargs) if "requests" in self.headers["User-Agent"]: @@ -51,7 +53,7 @@ def request(self, method, url, *args, **kwargs): return resp def solve_cf_challenge(self, resp, **original_kwargs): - sleep(5) # Cloudflare requires a delay before solving the challenge + sleep(self.delay) # Cloudflare requires a delay before solving the challenge body = resp.text parsed_url = urlparse(resp.url)