Skip to content

Commit

Permalink
Add delay as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
aforaster committed Feb 5, 2018
1 parent 428e147 commit 265b65b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cfscrape/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand All @@ -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)
Expand Down

0 comments on commit 265b65b

Please sign in to comment.