rewrite invalid cloudflare redirect locations

After solving a challenge on komikcast.com, cloudflare would redirect to
https:/komikcast.com (with only one '/') when testing on TravisCI.
This commit is contained in:
Mike Fährmann 2019-04-27 16:22:42 +02:00
parent 0d7e8be987
commit 76df628b13
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -59,8 +59,11 @@ def solve_challenge(session, response, kwargs):
log.debug("Headers:\n%s", cf_response.headers)
log.debug("Content:\n%s", cf_response.text)
raise exception.StopExtraction()
if location[0] == "/":
location = root + location
else:
location = re.sub(r"(https?):/(?!/)", r"\1://", location)
for cookie in cf_response.cookies:
if cookie.name == "cf_clearance":