1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 03:02:50 +01:00

request 'transparent.gif' when solving Cloudflare challenges

This currently also works without, but they might be using these to
detect potential bots in the future.
This commit is contained in:
Mike Fährmann 2020-06-10 21:04:33 +02:00
parent 036a40943a
commit b0b1feaa67
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -33,11 +33,21 @@ def solve_challenge(session, response, kwargs):
parsed = urllib.parse.urlsplit(response.url)
root = parsed.scheme + "://" + parsed.netloc
page = response.text
try:
params = {"ray": text.extract(page, '?ray=', '"')[0]}
url = root + "/cdn-cgi/images/trace/jschal/nojs/transparent.gif"
session.request("GET", url, params=params)
url = root + "/cdn-cgi/images/trace/jschal/js/nocookie/transparent.gif"
session.request("GET", url, params=params)
except Exception:
pass
cf_kwargs = {}
headers = cf_kwargs["headers"] = collections.OrderedDict()
params = cf_kwargs["data"] = collections.OrderedDict()
page = response.text
url = root + text.unescape(text.extract(page, 'action="', '"')[0])
headers["Referer"] = response.url