Skip to content

Commit

Permalink
Merge pull request #137 from arnau-foraster/master
Browse files Browse the repository at this point in the history
Add delay as parameter
  • Loading branch information
Anorov authored Feb 5, 2018
2 parents 428e147 + 265b65b commit 8bf4daf
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 8bf4daf

Please sign in to comment.